cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Downloading shared file python API

Downloading shared file python API

Laurielounge
Explorer | Level 3

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

5 Replies 5

Greg-DB
Dropbox Staff

If you have a standard Dropbox shared link, you can use the 'sharing_get_shared_link_file' method to download the file:

https://dropbox-sdk-python.readthedocs.io/en/latest/api/dropbox.html#dropbox.dropbox.Dropbox.sharing...

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.

Laurielounge
Explorer | 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

 

Laurielounge
Explorer | 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, '')

Greg-DB
Dropbox Staff

Thanks for checking that and providing the additional information. As you found, the type of sharing you're using uses "/scl/fi/" link, as opposed to the standard "/s/". (The latter is what you get from the API itself, such as from sharing_create_shared_link_with_settings for a file, or when copying a shared link for a file manually.)

Unfortunately, the "/scl/fi/" kind of link isn't supported for downloading from the API, but I'll pass this along as a feature request. Apologies I don't have better news for you!

Greg-DB
Dropbox Staff

Downloading this kind of link via sharing_get_shared_link_file should work now. Please try again and let me know if you're still seeing any issues.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Laurielounge Explorer | Level 3
What do Dropbox user levels mean?