Source:
protected void onChunkedUploadStarted(ImageUploadQueue<UploadAction> imageUploadQueue) { final UploadAction uploadAction; if ((uploadAction = imageUploadQueue.poll()) == null) return; long tmpFileSize = getFileSize(uploadAction.getUploadData().getTargetUri()); int chunkSize = getChunkSize(); int expectedChunks = tmpFileSize < chunkSize ? 1 : (int) (tmpFileSize / chunkSize) + 1; MultipartBody.Part fileParts[] = new MultipartBody.Part[expectedChunks]; UploadPromise promise = new UploadPromise(); RestService restService; ArrayList<RequestBody> requestBodies; byte[] content; try (InputStream iStream = getContentResolver().openInputStream(uploadAction.getUploadData().getTargetUri())) { assert iStream != null; content = getBytes(iStream); } catch (FileNotFoundException e) { Log.e("UploadService", "FileNotFoundException", e.getCause()); content = new byte[0]; } catch (IOException e) { Log.e("UploadService", "IOException", e.getCause()); content = new byte[0]; } byte[][] splittedContent = splitArray(content, chunkSize); for (int i = 0; i < splittedContent.length; i++) { fileParts[i] = MultipartBody.Part.createFormData("file", uploadAction.getFileName(), RequestBody.create(MediaType.parse("image/*"), splittedContent[i])); } restService = restServiceFactory.createForAccount(userManager.getActiveAccount().getValue()); requestBodies = createUploadRequest(uploadAction.getFileName(), getPhotoName(uploadAction.getFileName()), userManager.getActiveAccount().getValue()); promise.setFileParts(fileParts); promise.setRequestBodies(requestBodies); promise.setCatId(uploadAction.getUploadData().getCategoryId()); promise.setCurrentChunk(0); promise.setTotalChunks(expectedChunks); if (uploadAction.getUploadData().getCategoryId() > 0) callChunkedUploadResponse(imageUploadQueue, restService, promise); }

Target:
protected void onChunkedUploadStarted(ImageUploadQueue<UploadAction> imageUploadQueue) { final UploadAction uploadAction; if ((uploadAction = imageUploadQueue.poll()) == null) return; long tmpFileSize = getFileSize(uploadAction.getUploadData().getTargetUri()); int chunkSize = getChunkSize(); int expectedChunks = tmpFileSize <= chunkSize ? 1 : (int) (tmpFileSize / chunkSize) + 1; MultipartBody.Part fileParts[] = new MultipartBody.Part[expectedChunks]; UploadPromise promise = new UploadPromise(); RestService restService; ArrayList<RequestBody> requestBodies; byte[] content; try (InputStream iStream = getContentResolver().openInputStream(uploadAction.getUploadData().getTargetUri())) { assert iStream != null; content = getBytes(iStream); } catch (FileNotFoundException e) { Log.e("UploadService", "FileNotFoundException", e.getCause()); content = new byte[0]; } catch (IOException e) { Log.e("UploadService", "IOException", e.getCause()); content = new byte[0]; } byte[][] splittedContent = splitArray(content, chunkSize); for (int i = 0; i < splittedContent.length; i++) { fileParts[i] = MultipartBody.Part.createFormData("file", uploadAction.getFileName(), RequestBody.create(MediaType.parse("image/*"), splittedContent[i])); } restService = restServiceFactory.createForAccount(userManager.getActiveAccount().getValue()); requestBodies = createUploadRequest(uploadAction.getFileName(), getPhotoName(uploadAction.getFileName()), userManager.getActiveAccount().getValue()); promise.setFileParts(fileParts); promise.setRequestBodies(requestBodies); promise.setCatId(uploadAction.getUploadData().getCategoryId()); promise.setCurrentChunk(0); promise.setTotalChunks(expectedChunks); if (uploadAction.getUploadData().getCategoryId() > 0) callChunkedUploadResponse(imageUploadQueue, restService, promise); }