Forum Discussion

thediez's avatar
thediez
Explorer | Level 3
4 years ago

PDF content gets corrupted after "filesUpload"

Hi,

I am trying to upload a pdf with valid content from mobile device to Dropbox but having trouble with the uploaded file that seems to get corrupted while being uploaded. It is a React Native (Expo) app. 

Please refer to the attachment for the code that I am using.

I have also tried to download the file and open it in Notepad++ and can see its content (see attached).

What's that I am wrong? I have tried to send the content to "filesupload" as binary as well but the uploaded pdf file is still corrupted.

Many thanks in advance.

 

 

1 Reply

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    When uploading files to Dropbox, you should just supply the raw binary data. In the code here, there are two things that look like they may be altering or affecting the format of the data you're sending: 1) 'base64: true' on your printToFileAsync method and 2) readAsStringAsync. Those methods aren't made by Dropbox though so I can't say what exactly they do or offer guidance on those, so I recommend referring to the documentation for those for information on using them accordingly.

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!