Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download Folder including Subfolder via wget from Dropbox link to Unix Server

I have a dropbox link like https://www.dropbox.com/sh/w4366ttcz6/AAB4kSz3adZ which opens the ususal dropbox site with folders and files. Is there any chance to download the complete content (tar or directly as sync) to a unix machine using wget? I have seen some posts here where single files were downloaded but could not find any answer to this. There is an api from Dropbox but that does not work on my server due to the 64 bit issue on my server and http://www.dropboxwiki.com/dropbox-addons/dropbox-gallery-download#BASH_Version does also not work for me.... any other suggestions?

like image 315
user2338300 Avatar asked Nov 10 '15 07:11

user2338300


People also ask

How do I download from Dropbox wget?

I just went to my Dropbox account, selected my file, click share on right side, a popup will show up then click on Share file and finally click on Copy link, the link will be saved into your clipboard.

Can I download entire folders from Dropbox?

You can download files and folders to your computer from your Dropbox account. To do so: Sign in to dropbox.com. Hover over the file or folder you'd like to download.

Can you download from Dropbox shared link?

You can make simple modifications to Dropbox links to share files the way you want. You can append the link URL to force the content to download or render in your browser.


3 Answers

This help article documents some parameters you can use to get different behaviors from Dropbox shared links:

https://www.dropbox.com/help/201

For example, using this link:

https://www.dropbox.com/sh/igoku2mqsjqsmx1/AAAeF57DR2ou_nZGC4JPoQKfa

We can use the dl parameter to get a direct download. Using curl, we can download it as such:

curl -L https://www.dropbox.com/sh/igoku2mqsjqsmx1/AAAeF57DR2ou_nZGC4JPoQKfa?dl=1 > download.zip

(The -L is necessary in order to follow redirects.)

Or, with wget, something like:

wget --max-redirect=20 -O download.zip https://www.dropbox.com/sh/igoku2mqsjqsmx1/AAAeF57DR2ou_nZGC4JPoQKfa
like image 192
Greg Avatar answered Sep 16 '22 15:09

Greg


You can use --content-disposition with wget too.

wget https://www.dropbox.com/sh/igoku2mqsjqsmx1/AAAeF57DR2ou_nZGC4JPoQKfa --content-disposition

It will auto-detect the folder name as the zip filename.

like image 28
korakot Avatar answered Sep 20 '22 15:09

korakot


Currently, you're probably better off creating an app that you don't publish, which can either access all your files, or just a dedicated app folder (safer). Click the generate API token button about halfway down the app's settings page, and store it securely! You can then use the dedicated download or zip download API calls to get your files from anywhere like so:

curl -X POST https://content.dropboxapi.com/2/files/download_zip \
    --header "Authorization: Bearer $MY_DROPBOX_API_TOKEN" \
    --header 'Dropbox-API-Arg: {"path": "/path/to/directory"}' \
    > useful-name.zip

Adding your token as an environment variable makes it easier & safer to type/script these operations. If you're using BASH, and you have ignorespace in your $HISTCONTROL you can just type + paste your key with a leading space so it's not saved in your history. For frequent use, save it in a file with 0600 permissions that you can source, as you would an SSH key.

 export MY_DROPBOX_API_TOKEN='...'
like image 23
Walf Avatar answered Sep 20 '22 15:09

Walf