We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Olaf B.2
10 years agoNew member | Level 2
downloading a large file using python v2 API
Dear Dropboxers,
would it be possible to see an example for large file download, equivalent to https://www.dropboxforum.com/hc/en-us/community/posts/205544836-python-upload-big-file-example for the...
- 10 years ago
It is already implemented in the Java SDK.
(It is also implemented in the API v1 Python client, but I can't recommend using that as it's deprecated.)
If you wanted to implement it manually, or modify the Python SDK, here's a sample of what it would look like in curl for reference:
curl -X POST https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer ACCESS_TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/test.txt\"}" \
--header "Range:bytes=0-2"That would download just the first 3 bytes of the file at /test.txt.
Greg-DB
Dropbox Community Moderator
10 years agoHi Matt, it sounds like your request may actually be slightly different than what was being discussed on this thread. We were talking about downloading files in distinct chunks (similar to the chunked upload), but it sounds like you want to be able to stream the download as desired, like you currently do with the get_file method.
I believe the files_download method does already work the same way as that though. It returns a requests.models.Response object on which you can call iter_content to iterate over the content, streaming it off the connection.
That would look something like:
metadata, res = dbx.files_download(path)
for data in res.iter_content(10):
print(data)
Hope this helps!
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!