I've used the following code for uploading a file through a shell script in Automator on macOS:
DROPBOX_TOKEN="MY-TOKEN"
FILE=$1
FILENAME=$(basename "$FILE")
UPLOAD=`curl -sX POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $DROPBOX_TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/psds/$FILENAME\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"$FILE"`
That works like a charm. I am then using IFTTT with an applet that looks for new files in this folder and then creates a Tumblr post with the file, using it's previewUrl as the caption. This preview URL is by default only allowing me as the owner to see the file. I'm looking into if there is a way to give the file public access when uploading it.
So I tried adding this to the shell script:
UPLOAD=`curl -sX POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings \
--header "Authorization: Bearer $DROPBOX_TOKEN" \
--header "Dropbox-API-Arg: {\"path\": \"/psds/$FILENAME\",\"settings\": {\"audience\": \"public\",\"access\": \"viewer\",\"requested_visibility\": \"public\",\"allow_download\": true}}" \
--header "Content-Type: application/octet-stream" \
But that is not working. When looking on the file in Dropbox after the upload, it still says that only I got access to it.
Is there a way to give a file public access when uploading it through the API like this?