Skip to content

Instantly share code, notes, and snippets.

@Lance-DC
Created October 13, 2019 05:23
Show Gist options
  • Select an option

  • Save Lance-DC/8d529817676ace1c6755351aef6ee1fb to your computer and use it in GitHub Desktop.

Select an option

Save Lance-DC/8d529817676ace1c6755351aef6ee1fb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This script will download a file from a directory in your Dropbox account.
# You will need to create a Dropbox App with this link: https://www.dropbox.com/developers/apps/create
# then get an Access Token for it. Once you have the token you can add it to the script.
# The file will be downloaded to your current directory and will overwrite any existing file with the same name.
if (($#<2))
then echo "Error! Usage: $(basename $0) <dropbox_dir> <dropboxfile>" && exit 1
fi
readonly TOKEN=<Access_Token>
readonly DIR=$1
FILE=$2
BASENAME=$(basename $FILE)
curl -X POST https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer $TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/$DIR/$FILE\"}" > $FILE
ls -l $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment