One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
GameOnCloud
4 years agoNew member | Level 2
Upload-session/finish-batch merges all the files appended in that upload session
After creating a new upload session ID using upload-session/start (Sequential), I used upload-session/append to add 2 more files (5120 bytes each) in it and finally called upload-session/finish-batch to complete the upload process.
The issue seems to be in upload-session/finish-batch, which asks me to put the offset value of both the files as the total size of the session id (i.e., 5120 + 5120 = 10240). After doing so it seems like once both the files are uploaded, the bytes of the second file in the session queue were appended to the bytes of both the files.
This means if the contents of the first file were "This is first." and the contents of the second file were "This is second.", then the files that upload-session/finish-batch uploads is "This is first.This is second." And this happens to both files. Eventually, if you add a third file in the queue, say "This is third." then the uploaded file contents would be "This is first.This is second.This is third.".
This is a sample response (noticing how the content hash is the same for both the files which were appended to that upload session using upload-session/append). In this example, the size of the first file is 5120 bytes and the second file is 5307 bytes. And thus upload-session/finish-batch forced to set the offset of both the files to their sum (10427). This seems to have increased size for both the files and there seems no workaround as API refuses to accept any other offsets except this sum.
I wasn't able to try upload-session/start (Concurrent) as the API calls were stuck for some reason and didn't close when adding the last file using upload-session/append.
Any assistance would be very much appreciated
- ЗдравкоLegendary | Level 20
Hi GameOnCloud,
🙂 Seems, you have misunderstood the meaning of upload session. Let's take a look on upload process at all.
The simplest upload can be performed using 2/files/upload. Main drawback here is limitation, set to any single HTTP transaction to the Dropbox server, be up to 150MB size. Which mean you can't upload file bigger than 150MB using the call mentioned (or it's not guaranteed at least). Since all files you have mentioned are much smaller, you can use this simplest call without issues.
To upload bigger files, you have to split files content to parts no bigger than 150MB and send the parts to the Dropbox server. You can achieve this using upload session for every one file. Using 2/files/upload_session/start, you can start such a session for single big file upload (according to described by you, you have tried use it for more than 1 file simultaneously 😯). The parts of file split before can be added using 2/files/upload_session/append_v2. Once all file parts upload finished, you can finish the session and put the content uploaded within Dropbox file system as a named file using 2/files/upload_session/finish. 😉 In such a way single file upload can get completed using multiple transactions.
The final upload step is time consuming (not only related to upload time) since Dropbox file system have to be locked for new file addition (or any other change). When you have many files, this last step can be optimized by grouping multiple upload sessions in batch and finish their addition to the Dropbox with a single locking using 2/files/upload_session/finish_batch_v2. Single file for every one session passed!
Hope this clarifies matter and you can select a way matching your needs and organize your code better.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 12 hours ago
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 or Facebook.
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!