Skip to content

Instantly share code, notes, and snippets.

@mega-arbuz
Created January 24, 2019 22:30
Show Gist options
  • Save mega-arbuz/830938ac2878b95bc0cc94117a5e1ae9 to your computer and use it in GitHub Desktop.
Save mega-arbuz/830938ac2878b95bc0cc94117a5e1ae9 to your computer and use it in GitHub Desktop.
Upload to dropbox and get shareable link
#!/bin/bash
if [ $# -lt 3 ]; then echo "Missing parameters"; exit 1; fi
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer $1" \
--header "Dropbox-API-Arg: {\"path\": \"/builds/$2\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @$3 > /dev/null
echo $(curl -X POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings \
--header "Authorization: Bearer $1" \
--header "Content-Type: application/json" \
--data "{\"path\": \"/builds/$2\",\"settings\": {\"requested_visibility\": \"public\"}}" \
| grep -Po 'http.*dropbox.com.*[?]dl=')1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment