You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Laurielounge
6 years agoExplorer | Level 3
Downloading shared file python API
Hi all,
Python 3.6, using module dropbox.
I have a URL for a file shared from someone else's dropbox account. The file gets regularly updated (same name, same link). I wish to download from this link.
I can't seem to get at it. I have code that looks like:
import dropbox
access_token = 'ABC123yNOBAAAAAAAAAYq3fOaDy6C4Lj7QV9dckXDqkQfGM2LW2Oe9hI2LXSPyTj'
dbx = dropbox.Dropbox(access_token)
url1 = 'https://www.dropbox.com/l/scl/ABC123NXsA-8ndaH0aOaaSBR5AH78NMHPTw'
but I can't work out which endpoint to call.
Cheers,
---=L
- Greg-DBDropbox Staff
If you have a standard Dropbox shared link, you can use the 'sharing_get_shared_link_file' method to download the file:
Note, however, that the kind of link you posted here, with "/l/scl", is not a standard Dropbox shared link, but rather is a link intended only for manual use (e.g., sent via email). I'll send this along as a feature request to support this kind of link on the API though.
If you can follow the redirect on that link can get to a standard shared link however, with "/s/", you should be able to use the above method to download the data.
- LaurieloungeExplorer | Level 3
Hi Greg,
Thanks for the reply.
Now. this "/s/" type link. If I open the URL above, and log onto my Dropbox account, I end up at a URL that looks like:
https://www.dropbox.com/scl/fi/abc123lwaazd7qw1782a8/filename.mdb?dl=0&oref=e&r=ABc1239UH...
The page itself says ".mdb files can't pe previewed" (it's an Access file), and has a Download button with a Down triangle. Clicking on the button, my options are "Direct download" and "Save to my Dropbox". Can't see that ".../s/..." link anywhere.
Looking in the source code, quite late in the code I can see a json definition which looks like:
"file": {
"direct_blockserver_link": null,
"revision_id": "0123456780000010bed0280",
"preview": null,
"ts": 1548041627,
"sort_key": ["ABCdefRQCEIwLAEOAQ4A"],
"bytes": 47958016,
"preview_url": null,
"beacon_context": "ABC123I2BK93MmN3DY_YRsVuhGpnI9IrhK0",
"filename": "filename.mdb",
"sjid": 48,
"open_in_app_data": null,
"thumbnail_url_tmpl": null,
"href": "https://www.dropbox.com/scl/fi/abc123lwaazd7qw1782a8/filename.mdb?dl=0",
"file_id": "id:FFpFQXeecgAAAAAAAAAADQ",
"is_symlink": false,
"is_dir": false,
"preview_type": null,
"preview_thumbnail_url": null,
"ns_id": 1234569344,
"icon": "page_white_32"
},I cannot however see anything like a "https://www.dropbox.com/s/...". Nothing with "/s/" in it anywhere in the source. That "href" URL looks promising (and it's what's in the bowser url along with some other stuff) , so I'll try that for now, but if I'm totally barking up the wrong tree looking for the "good" url, let me know.
Thanks for your help here. Have been banging my head against this wall since December.
Regards,
---=L
- LaurieloungeExplorer | Level 3
Okay. No go on that link.
File "/usr/local/lib/python3.6/site-packages/dropbox/base.py", line 3350, in sharing_get_shared_link_file
None,
File "/usr/local/lib/python3.6/site-packages/dropbox/dropbox.py", line 274, in request
timeout=timeout)
File "/usr/local/lib/python3.6/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
timeout=timeout)
File "/usr/local/lib/python3.6/site-packages/dropbox/dropbox.py", line 454, in request_json_string
raise InternalServerError(request_id, r.status_code, r.text)
dropbox.exceptions.InternalServerError: InternalServerError('64c2c45dfd812b3bbbc893c67e834378', 503, '')
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,917 PostsLatest Activity: 11 days 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!