Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Surya K.'s avatar
Surya K.
New member | Level 1
9 years ago

Dropbox large file upload

 

Trying to upload big files with below code.

String upload_id = dbxFiles.uploadSessionStart().finish().getSessionId();
byte[] temp = new byte[CHUNK];
int size = inputStream.available();
int cursor = 0;
while (cursor < size) {

int totalRead = 0;
if ((size - cursor) < CHUNK) {
temp = new byte[size - cursor];
totalRead = inputStream.read(temp, 0, size - cursor);
} else {
totalRead = inputStream.read(temp, 0, CHUNK);
}
dbxFiles.uploadSessionAppend(upload_id, cursor).uploadAndFinish(new ByteArrayInputStream(temp));
cursor += totalRead;
}

uploadFileMetadata = dbxFiles.uploadSessionFinish(new UploadSessionCursor(upload_id, cursor),
new CommitInfo(path, WriteMode.ADD, true, new Date(), false)).uploadAndFinish(inputStream);

 

 

But the size of uploaded files are drastically changed. Can you please help me out

5 Replies

Replies have been turned off for this discussion
  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago

    When you say the size is "drastically changed," could you be more specific? What's the value of "size" and how big is the resulting upload? How big is "CHUNK"?

    One quick debugging tip: try printing out the value of "totalRead" and "cursor" before each call to the API. This might help track down the issue.

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago

    Have you tried adding the logging I suggested? What does it reveal?

  • Suryakant D.'s avatar
    Suryakant D.
    New member | Level 1
    9 years ago

    Logging I had already added before posting the issue here. Logs were fine. Everything was right. But after upload is finished and when I check the file size in Dropbox that is changed

  • Steve M.'s avatar
    Steve M.
    Icon for Dropbox Staff rankDropbox Staff
    9 years ago

    Could you share the log here (and the updated code that generates that log)?

    It's hard to help you debug this without being able to see what's happening.

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!