We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
advcha
6 years agoExplorer | Level 3
Pdf file corrupt after downloding
Hello,
I am using Sharetribe platform that I can't touch the server code but only get access on custom script. So I use jquery ajax to upload and download files to dropbox. The upload process went smooth but the download one has an issue that the downloaded file is corrupt. It can't be opened by any pdf software. I also found the size of the file bigger than the original pdf file in my dropbox. The original pdf file is good and can be opened perfectly.
Here is the code to download the file
var url = 'https://content.dropboxapi.com/2/files/download'; $.ajax({ url: url, type: 'post', responseType: 'arraybuffer', headers: { "Authorization": "Bearer <TOKEN>", "Dropbox-API-Arg": JSON.stringify({"path": "/"+filename}) }, success: function (data){ console.log(data); //CAN DOWNLOAD PDF BUT CAN'T OPEN IT. FILE PDF IS CORRUPT /*var blob = new Blob([data]); var aLink = document.createElement('a'); aLink.href = window.URL.createObjectURL(blob); aLink.download = "file_tc.pdf"; aLink.click();*/ const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' })); window.open(url); }, error: function (data){ console.log(data); } })
Anyone can help what's wrong with the above code?
[Cross-linking for reference: https://stackoverflow.com/questions/58569036/pdf-file-corrupt-after-downloding ]
In case anyone else comes across this with the same question, it looks like they already found a solution and posted it on StackOverflow here.
- Greg-DBDropbox Staff
[Cross-linking for reference: https://stackoverflow.com/questions/58569036/pdf-file-corrupt-after-downloding ]
In case anyone else comes across this with the same question, it looks like they already found a solution and posted it on StackOverflow here.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 days agoIf 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!