<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: downloading file with binary data. Not receiving entire contents of file. in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/downloading-file-with-binary-data-Not-receiving-entire-contents/m-p/225680#M12267</link>
    <description>&lt;P&gt;I was not setting the responseType of the xhr object to 'arraybuffer'. &amp;nbsp;Once I did that the download worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// ---------------------- 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();
}
&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Jun 2017 11:59:08 GMT</pubDate>
    <dc:creator>steve_lae0901</dc:creator>
    <dc:date>2017-06-14T11:59:08Z</dc:date>
    <item>
      <title>downloading file with binary data. Not receiving entire contents of file.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/downloading-file-with-binary-data-Not-receiving-entire-contents/m-p/225647#M12262</link>
      <description>&lt;P&gt;javascript, running in the browser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using XMLHttpRequest and the content.dropboxapi.com/2/files/download endpoint to download a zip file from my dropbox folder. &amp;nbsp;I am receiving the file. But the last 100 or so bytes are missing. &amp;nbsp;Why am I not receiving the entire contents of the file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the size of the file from the list_folder API. That number is a little bit larger than the length of the xhr.response property. &amp;nbsp;And when I pass xhr.response to a function that treats the response data as a zip file stream, the error says the file cannot be unzipped. &amp;nbsp;The error says missing xxx number of bytes. That number matches the number of bytes that are missing from the download.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// ---------------------- 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.length ;                                         
        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.setRequestHeader('Authorization', 'Bearer ' + token );                    
  xhr.setRequestHeader('Dropbox-API-Arg', JSON.stringify({ path: path })) ;     
  xhr.send();
}

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:21:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/downloading-file-with-binary-data-Not-receiving-entire-contents/m-p/225647#M12262</guid>
      <dc:creator>steve_lae0901</dc:creator>
      <dc:date>2019-05-29T09:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: downloading file with binary data. Not receiving entire contents of file.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/downloading-file-with-binary-data-Not-receiving-entire-contents/m-p/225680#M12267</link>
      <description>&lt;P&gt;I was not setting the responseType of the xhr object to 'arraybuffer'. &amp;nbsp;Once I did that the download worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// ---------------------- 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();
}
&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jun 2017 11:59:08 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/downloading-file-with-binary-data-Not-receiving-entire-contents/m-p/225680#M12267</guid>
      <dc:creator>steve_lae0901</dc:creator>
      <dc:date>2017-06-14T11:59:08Z</dc:date>
    </item>
  </channel>
</rss>

