Skip to content Skip to sidebar Skip to footer

Programmatically Download Content From Shared Dropbox Folder Links

I'm building an application to automatically trigger a download of a Dropbox file shared with a user (shared file/folder link). This was straight forward to implement for Dropbox

Solution 1:

Dropbox's support team just filled me in on the best way to do this:

Just add ?dl=1 to the end of the shared link. That'll give you a zipped version of the shared folder.

So if the link shared with a user is https://www.dropbox.com/sh/xyz/xyz-YZ (or similar, which links to a shared folder), to download a zipped version of that folder just access https://www.dropbox.com/sh/xyz/xyz-YZ?dl=1

Hope this helps someone else also.

Solution 2:

When downloading direct shared links to files through python I was getting html pages instead of actual file content. Changing ?dl=1 wasn't helping. I then noticed that wget was downloading the actual file, even when ?dl=0. Seems like dropbox detects wget user agent and responds with the file, so setting the user agent header to Wget/1.16 (linux-gnu) in python solved the issue, now any dropbox shared link is being downloaded properly:

headers = {'user-agent': 'Wget/1.16 (linux-gnu)'}
r = requests.get(url, stream=True, headers=headers)
withopen(filepath, 'wb') as f:
    for chunk in r.iter_content(chunk_size=1024): 
        if chunk:
            f.write(chunk)

Solution 3:

This should really be done by using the awesome Dropbox Core API, which allows you to upload or download files, see information on file deltas and information on shared folders/files.

The API is rather simple, as it returns a common URL to download any item from Dropbox accounts with.

Post a Comment for "Programmatically Download Content From Shared Dropbox Folder Links"