You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
steve_lae0901
8 years agoHelpful | Level 6
downloading file with binary data. Not receiving entire contents of file.
javascript, running in the browser.
using XMLHttpRequest and the content.dropboxapi.com/2/files/download endpoint to download a zip file from my dropbox folder. I am receiving the file. But th...
- 8 years ago
I was not setting the responseType of the xhr object to 'arraybuffer'. Once I did that the download worked.
// ---------------------- dropbox_GetFile_http ------------------------ function dropbox_GetFile_http( path, token ) { var xhr = new XMLHttpRequest( ) ; xhr.onreadystatechange = function( ) { if ( xhr.readyState == XMLHttpRequest.DONE) { if (xhr.status == 200) { var lx = xhr.response.byteLength ; console.log( 'got data. ' + 'lgth:' + lx ) ; unzip( xhr.response ) ; } else { var msg = 'status:' + xhr.status ; console.log( msg ) ; } } } ; var runAsync = true ; xhr.open('POST', 'https://content.dropboxapi.com/2/files/download', runAsync); xhr.responseType = 'arraybuffer' ; xhr.setRequestHeader('Authorization', 'Bearer ' + token ); xhr.setRequestHeader('Dropbox-API-Arg', JSON.stringify({ path: path })) ; xhr.send(); }
steve_lae0901
8 years agoHelpful | Level 6
I was not setting the responseType of the xhr object to 'arraybuffer'. Once I did that the download worked.
// ---------------------- dropbox_GetFile_http ------------------------ function dropbox_GetFile_http( path, token ) { var xhr = new XMLHttpRequest( ) ; xhr.onreadystatechange = function( ) { if ( xhr.readyState == XMLHttpRequest.DONE) { if (xhr.status == 200) { var lx = xhr.response.byteLength ; console.log( 'got data. ' + 'lgth:' + lx ) ; unzip( xhr.response ) ; } else { var msg = 'status:' + xhr.status ; console.log( msg ) ; } } } ; var runAsync = true ; xhr.open('POST', 'https://content.dropboxapi.com/2/files/download', runAsync); xhr.responseType = 'arraybuffer' ; xhr.setRequestHeader('Authorization', 'Bearer ' + token ); xhr.setRequestHeader('Dropbox-API-Arg', JSON.stringify({ path: path })) ; xhr.send(); }
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months 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!