Created
January 26, 2023 16:15
-
-
Save larsvilhuber/7e3c6032cea1e1e18920bcd7abe51aa7 to your computer and use it in GitHub Desktop.
Short script to upload to Dropbox from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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