Search code examples
bashcurldropbox

malformed_path for uploading file into my dropbox


Local spurce file : /tmp/back/wp.bak.sql
Dst file : /
my access token is xxxxxx.
I want to upload the /tmp/back/wp.bak.sql in my local pc into dropbox root directory,and keep the name unchanged.

curl command 1:

curl -X POST  https://content.dropboxapi.com/2/files/upload \
  --header 'Authorization: Bearer xxxxxx' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"/"}' \
  --data-binary @'/tmp/back/wp.bak.sql' 

Output info.

{"error_summary": "path/malformed_path/...", "error": {".tag": "path", "reason": {".tag": "malformed_path"}, "upload_session_id": ""}}

curl command 2:

cd /tmp/back
curl -X POST  https://content.dropboxapi.com/2/files/upload \
  --header 'Authorization: Bearer xxxxxx' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"/"}' \
  --data-binary @'wp.bak.sql' 

Same error info. How to fix the malformed_path for my curl command?


Solution

  • Enter the full path of your file in the path field :

    --header 'Dropbox-API-Arg: {"path":"/wp.bak.sql"}'
    

    So :

    curl "https://content.dropboxapi.com/2/files/upload" \
      -H 'Authorization: Bearer xxxxxx' \
      -H 'Content-Type: application/octet-stream' \
      -H 'Dropbox-API-Arg: {"path":"/wp.bak.sql"}' \
      --data-binary @'wp.bak.sql'