Basically this is the command to upload a file:
$CURL_BIN $CURL_ACCEPT_CERTIFICATES $CURL_PARAMETERS -i --globoff -o "$RESPONSE_FILE" --upload-file "$FILE_SRC" "$API_UPLOAD_URL/$ACCESS_LEVEL/$FILE_DST?
oauth_consumer_key=$APPKEY&
oauth_token=$OAUTH_ACCESS_TOKEN&
oauth_signature_method=PLAINTEXT&
oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&
oauth_timestamp=$time&
oauth_nonce=$RANDOM"
I will decipher more it later, and share a simpler bash script...
CURL_BIN="curl"
CURL_ACCEPT_CERTIFICATES="-k"
CURL_PARAMETERS="--progress-bar"
CURL_PARAMETERS="-s --show-error"
TMP_DIR="/tmp"
RESPONSE_FILE="$TMP_DIR/du_resp_$RANDOM"
RANDOM = just random int...
FILE_SRC = well, the file...
FILE_DST = on the other end...
API_UPLOAD_URL="
https://api-content.dropbox.com/1/files_put"
ACCESS_LEVEL="dropbox"
These I don't know yet where to fetch yet:
APPKEY = This is supplied by you...
APPSECRET = This is supplied by you...
These are tricky:
OAUTH_ACCESS_TOKEN_SECRET=
OAUTH_ACCESS_TOKEN=
Code below, don't know for how long these are valid, if they should be stored or fetched every time:
OAuth is such a tragic moment in web history!
Code: Select all
time=$(utime)
$CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o $RESPONSE_FILE --data "oauth_consumer_key=$APPKEY&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26&oauth_timestamp=$time&oauth_nonce=$RANDOM" "$API_REQUEST_TOKEN_URL"
OAUTH_TOKEN_SECRET=$(sed -n 's/oauth_token_secret=\([a-z A-Z 0-9]*\).*/\1/p' "$RESPONSE_FILE")
OAUTH_TOKEN=$(sed -n 's/.*oauth_token=\([a-z A-Z 0-9]*\)/\1/p' "$RESPONSE_FILE")
if [ -n "$OAUTH_TOKEN" -a -n "$OAUTH_TOKEN_SECRET" ]; then
echo -ne "OK\n"
else
echo -ne " FAILED\n\n Please, check your App key and secret...\n\n"
remove_temp_files
exit 1
fi
while (true); do
#USER AUTH
echo -ne "\n Please visit this URL from your Browser, and allow Dropbox Uploader\n"
echo -ne " to access your DropBox account:\n\n --> ${API_USER_AUTH_URL}?oauth_token=$OAUTH_TOKEN\n"
echo -ne "\nPress enter when done...\n"
read
#API_ACCESS_TOKEN_URL
echo -ne " > Access Token request... "
time=$(utime)
$CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o $RESPONSE_FILE --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_TOKEN_SECRET&oauth_timestamp=$time&oauth_nonce=$RANDOM" "$API_ACCESS_TOKEN_URL"
OAUTH_ACCESS_TOKEN_SECRET=$(sed -n 's/oauth_token_secret=\([a-z A-Z 0-9]*\)&.*/\1/p' "$RESPONSE_FILE")
OAUTH_ACCESS_TOKEN=$(sed -n 's/.*oauth_token=\([a-z A-Z 0-9]*\)&.*/\1/p' "$RESPONSE_FILE")
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.