Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
feni
6 years agoExplorer | Level 4
How to upload files in batch?
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 upload...
Greg-DB
Dropbox Community Moderator
6 years agoWe 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()feni
6 years agoExplorer | Level 4
It is very sad that such a big cloud storage does not have reliable uploading function in their SDK.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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!