Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.
Forum Discussion
TalesDragon
4 years agoExplorer | Level 3
Corrupt file when transferring
Hello,
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", "https://content.dropboxapi.com/2/files/upload", .f.)
oHttp:setRequestHeader("Authorization","Bearer " + alltrim(Taux_Token) )
oHttp:setRequestHeader("Content-Type", "application/octet-stream")
oHttp:setRequestHeader("Dropbox-API-Arg", Taux_API_Arg )
oHttp:Send(cEncBuff)
***
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.
Grateful
1 Reply
- Greg-DB4 years ago
Dropbox Community Moderator
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,039 PostsLatest Activity: 2 days ago
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 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!