Skip to content

Instantly share code, notes, and snippets.

View sponnusamy's full-sized avatar

Selvakumar Ponnusamy sponnusamy

View GitHub Profile
@sponnusamy
sponnusamy / ResumeUpload.java
Created February 1, 2019 10:22
Upload or Resume file upload
int currentPart = Integer.parseInt(fi.metadata.get("currentPart"));
// Upload the file parts.
long filePosition = fi.offset;
long contentLength = fi.entityLength;
long transferred = 0;
try (ReadableByteChannel rbc = Channels.newChannel(request.getInputStream());
InputStream is = Channels.newInputStream(rbc)) {
for (int i = currentPart + 1; filePosition < contentLength; i++) {
long partSize = Math.min(MULTI_PART_SIZE, (fi.entityLength - filePosition));