We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

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

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
    5 years ago

    Hi All

    Thanks for your help.

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

     

    Thanks Again

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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

      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

        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).

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 12 months ago
325 Following

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 or Facebook.

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!