Example of DropBox API PUT using Curl and Oauth 2 to Upload a file to DropBox

后端 未结 3 1050

I am searching everywhere and haven\'t been able to locate a suitable example and am not well versed enough to be able to sort it out via the docs. Could someone with more

相关标签:
3条回答
  • 2020-12-31 20:04

    You need an access token for the account. (This is typically acquired by going through the OAuth flow, but you can also get one for your own account by clicking the "Generate" button on the page for your Dropbox app. See https://www.dropbox.com/developers/blog/94/generate-an-access-token-for-your-own-account.)

    Once you have an access token, your curl command should probably work, though I prefer --header "Authorization:Bearer abc123xyz" over putting the access token in a query parameter. Also, drop the Content-Type: multipart/mixed, since that's not what you're sending.

    I'd also recommend "auto" instead of "dropbox," just because it always does the right thing regardless of the app type.

    0 讨论(0)
  • 2020-12-31 20:07

    Here is working codes to upload file in dropbox via CURL request.

    curl -X POST https://content.dropboxapi.com/2/files/upload \
      --header "Authorization: Bearer <your token>" \
      --header "Dropbox-API-Arg: {\"path\": \"/file_path.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
      --header "Content-Type: application/octet-stream" \
      --data-binary "@file_path.txt"
    
    0 讨论(0)
  • 2020-12-31 20:18

    If you have an access token (created via the app console):

    curl -H "Authorization: Bearer <your token>" https://api-content.dropbox.com/1/files_put/auto/ -T <your file path>
    
    0 讨论(0)
提交回复
热议问题