Showing results for 
Show  only  | Search instead for 
Did you mean: 
We love to hear how every person gets the most from Dropbox, and it seems everyone has a slightly different use for it - tell us yours here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

Showing results for 
Show  only  | Search instead for 
Did you mean: 

Corrupt file when transferring

Corrupt file when transferring

Explorer | Level 3

follow my code below:


Taux_API_Arg  = '{'
Taux_API_Arg += '"path":"/codechain/extrato.pdf",'
Taux_API_Arg += '"mode":"overwrite",'
Taux_API_Arg += '"autorename":true,'
Taux_API_Arg += '"mute":false'
Taux_API_Arg += '}'

cBuff := FileStr("C:\Onedrive\fontes\ManagerDropbox\extrato.pdf")
cEncBuff := hb_Base64Encode( cBuff, Len( cBuff ) )

oHttp := CreateObject("MSXML2.ServerXMLHTTP.6.0")
oHttp:Open("POST", "", .f.)
oHttp:setRequestHeader("Authorization","Bearer " + alltrim(Taux_Token) )
oHttp:setRequestHeader("Content-Type", "application/octet-stream")
oHttp:setRequestHeader("Dropbox-API-Arg", Taux_API_Arg )


The file is transferred to the Dropbox repository, but with a larger size, therefore corrupted !!

Original size: 58.28 Kb
Size after download: 77.44 Kb

PS: Transferring by POSTMAN, works correctly.

1 Reply 1

Re: Corrupt file when transferring


The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw file data to be uploaded as 'application/octet-stream' in the request body. That being the case, you should send only the file data in the request body, without any additional encoding. I see in your code, for instance, that you appear to be applying a layer of base64 encoding, via the hb_Base64Encode call. You should remove that, and make sure you're only sending the expected bytes for the file.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?