Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

jimbob1977's avatar
jimbob1977
Helpful | Level 6
6 years ago
Solved

API Upload Always Zero

Hi

When I upload a file using the code below the file appears in my folder at zero size.

Uploading the file manually works fine. so I know the file is ok

I've looked thru similar old posts but I'm still struggling - any advice??

 

curl -X POST https://content.dropboxapi.com/2/files/upload \
  --header 'Authorization: Bearer MYTOKEN' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}' 
  --data-binary @"/Splash.jpeg"
  • jimbob1977's avatar
    jimbob1977
    6 years ago

    Hi All

    Thanks for your help.

    My fault - I had an error in the file path to Data Binary

     

    Thanks Again

4 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    It looks like you don't have a continuation "\" on the second to last line, like there is on the other lines, so the last line may not actually be given to curl which would result in no data being upload. Try adding that "\" back.

  • jimbob1977's avatar
    jimbob1977
    Helpful | Level 6
    6 years ago

    Hi 

    So First I Tried This (Adding The /)

     

    curl -X POST https://content.dropboxapi.com/2/files/upload \
      --header 'Authorization: Bearer MYTOKEN' \
      --header 'Content-Type: application/octet-stream' \
      --header 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}'\ 
      --data-binary @"/Splash.jpeg"

    This Gave The Response.

    -bash: --data-binary: command not found

     

    So I Put A Space Between ' & \ To Give.

     

    curl -X POST https://content.dropboxapi.com/2/files/upload \
      --header 'Authorization: Bearer MYTOKEN' \
      --header 'Content-Type: application/octet-stream' \
      --header 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}' \ 
      --data-binary @"/Splash.jpeg"

    Now I Get The Response

     

    curl: (6) Could not resolve host: 

     

    Both Add The File But Both At Zero Content????

     

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    6 years ago

    Hi jimbob1977,

    What are results from following commands:

    host content.dropboxapi.com
    stat /Splash.jpeg

    If the above commands results are as expected, probably you have messed up curl command arguments. Try to put everything on a single line:

    curl -X POST https://content.dropboxapi.com/2/files/upload -H 'Authorization: Bearer MYTOKEN' -H 'Content-Type: application/octet-stream' -H 'Dropbox-API-Arg: {"path":"/RoomVT/Clown2.jpeg"}' --data-binary @/Splash.jpeg

    If some error brings up again, post entire error, not just part (i.e. which host couldn't be resolved, for example).

  • jimbob1977's avatar
    jimbob1977
    Helpful | Level 6
    6 years ago

    Hi All

    Thanks for your help.

    My fault - I had an error in the file path to Data Binary

     

    Thanks Again

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!