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

痴心易碎 提交于 2020-12-28 14:52:56

问题


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?


回答1:


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



回答2:


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='...'



回答3:


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.




回答4:


Yes you can as it is pretty wasy follow below steps

Firstly, get the dropbox share link. It will look like this https://www.dropbox.com/s/ad2arn440pu77si/test.txt

Then add a “?dl=1” to the end of that url and a “-O filename” so that you end up with something like this: wget https://www.dropbox.com/s/ad2arn440pu77si/test.txt?dl=1 -O test.txt

Now you can easily get files onto your linux.



来源:https://stackoverflow.com/questions/33624523/download-folder-including-subfolder-via-wget-from-dropbox-link-to-unix-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!