Skip to content

Instantly share code, notes, and snippets.

@larsvilhuber
Created January 26, 2023 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsvilhuber/7e3c6032cea1e1e18920bcd7abe51aa7 to your computer and use it in GitHub Desktop.
Save larsvilhuber/7e3c6032cea1e1e18920bcd7abe51aa7 to your computer and use it in GitHub Desktop.
Short script to upload to Dropbox from the command line
#!/bin/bash
# Based on https://stackoverflow.com/questions/42120767/upload-file-on-linux-cli-to-dropbox-via-bash-sh
# This is in principle superseded by Dropbox CLI
## OAUTH_DROPBOX is pulled from environment
if [ -z $OAUTH_DROPBOX ]
then
echo "No oauth token"
exit 2
fi
list=$1
[[ -z $list ]] && exit 2
for file in $(cat $list)
do
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $OAUTH_DROPBOX" \
--header "Dropbox-API-Arg: {\"path\": \"/${file#./*}\"} " \
--header "Content-Type: application/octet-stream" \
--data-binary @${file#./*}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment