@@ -0,0 +1,1426 @@
+package util;%0A%0Aimport exception.UploadException;%0Aimport okhttp3.MediaType;%0Aimport okhttp3.RequestBody;%0Aimport okio.BufferedSink;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.io.IOException;%0Aimport java.io.RandomAccessFile;%0Aimport java.net.SocketException;%0A%0A/**%0A * Custom RequestBody to handle reading from a section of a file rather than the entire file.%0A */%0Apublic class ChunkRequestBody extends RequestBody %7B%0A    private String filepath;%0A    private long offset;%0A    private int chunkSize;%0A    private MediaType mediaType;%0A%0A    public ChunkRequestBody(String filepath, MediaType mediaType, long offset, int chunkSize) %7B%0A        this.filepath = filepath;%0A        this.mediaType = mediaType;%0A        this.offset = offset;%0A        this.chunkSize = chunkSize;%0A    %7D%0A%0A    @Nullable%0A    @Override%0A    public MediaType contentType() %7B%0A        return this.mediaType;%0A    %7D%0A%0A    @Override public long contentLength() %7B%0A        return chunkSize;%0A    %7D%0A%0A    @Override%0A    public void writeTo(BufferedSink sink) throws IOException %7B%0A        RandomAccessFile source = new RandomAccessFile(filepath, %22r%22);%0A        byte%5B%5D bytes = new byte%5BUpload.CHUNK_SIZE%5D;%0A%0A        source.seek(offset);%0A        source.read(bytes, 0, chunkSize);%0A        source.close();%0A%0A        try %7B%0A            sink.write(bytes, 0, chunkSize);%0A            sink.close();%0A        %7D catch (SocketException e)%7B%0A            throw new UploadException();%0A        %7D%0A    %7D%0A%7D%0A

Add custom RequestBody to upload file chunks