Add files to dropbox with single curl command

2019-07-08 1 min read bash

I have been thinking of posting this for sometime now. This is very useful, when you are working on a different Linux box and want to upload a file to dropbox.

 

So, before you run this command, you need to create your auth token in Dropbox developer API page. Once that is done, need to change the 2 parameters in command below. Export your Access token and run the below command.

Here is the command:

tar cvzf /tmp/backup.tgz <folder of your choice>
curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer $OAUTH_ACCESS_TOKEN" \
    --header "Dropbox-API-Arg: {\"path\": \"/<dropbox path>/$(hostname -s)/$NOW.tgz\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary @/tmp/backup.tgz
comments powered by Disqus