Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Suppose I have some files I'd like to upload to a folder on Dropbox using dropbox-sdk-python. Some of the files are more than 150 MB, some of them less than 1 MB.
The documentation recommends uploading many files in parallel and offers 6 functions for that:
```
'files_upload_session_append',
'files_upload_session_append_v2',
'files_upload_session_finish',
'files_upload_session_finish_batch',
'files_upload_session_finish_batch_check',
'files_upload_session_start'
```
There are a lot of recomendations in their documentation but I did not find a complete example for doing such a common thing. I did not use Dropbox API before and I dont know in which way I should organize all the upload functions. Can anybody share a complete example for batch uploading?
We don't currently have an official sample for that using the Python SDK in particular, but I'll pass this along as request for one.
Here's an example I put together for uploading a large files using upload sessions though: (note, I haven't tested this extensively, and it doesn't have any error handling)
f = open(file_path) file_size = os.path.getsize(file_path) CHUNK_SIZE = 4 * 1024 * 1024 if file_size <= CHUNK_SIZE: print dbx.files_upload(f.read(), dest_path) else: upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE)) cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id, offset=f.tell()) commit = dropbox.files.CommitInfo(path=dest_path) while f.tell() <= file_size: if ((file_size - f.tell()) <= CHUNK_SIZE): print dbx.files_upload_session_finish(f.read(CHUNK_SIZE), cursor, commit) break else: dbx.files_upload_session_append_v2(f.read(CHUNK_SIZE), cursor) cursor.offset = f.tell() f.close()
It is very sad that such a big cloud storage does not have reliable uploading function in their SDK.
Hi there!
If you need more help you can view your support options (expected response time for a 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!