I have a problem downloading a file from a Node.js server (using Express). The request is handled properly and the response.download file is called on an existing file. But when the data is received in the client, not all data is received and the blob created from it is bloated to almost twice the size.
The server part (Node.js using Express), where i route a post to /php/mixMovie.php, a re-implementation of an existing backend, is this:
app.post( '/php/mixMovie.php', function( request, response ){
....
console.log( 'serving ' + destFile );
fs.stat( destFile, function (err, stats) {
console.log(stats.size);
});
response.download( destFile );
});
giving the console output:
serving /Users/j/[...]/WTSc5e8f500-ad76-4fe5-b368-3a0f3e848813.ogg
326049
serving /Users/j/[...]/WTSc5e8f500-ad76-4fe5-b368-3a0f3e848813.ogg
326049
...
the client has this javascript code:
$.ajax({
type: 'POST',
url: 'http://localhost:8000/php/mixMovie.php',
data: fd,
processData: false,
contentType: false
} ).done( function( data ){
console.log( data.length );
var bb = new Blob( [ data ], { type:'movie/ogg' } );
console.log( bb.size );
} );
giving this surprising output:
XHR finished loading: ("http://localhost:8000/php/mixMovie.php"). jquery-1.8.3.js:8434
314947
600641
XHR finished loading: ("http://localhost:8000/php/mixMovie.php"). jquery-1.8.3.js:8434
315028
600737
XHR finished loading: ("http://localhost:8000/php/mixMovie.php"). jquery-1.8.3.js:8434
315020
600439
XHR finished loading: ("http://localhost:8000/php/mixMovie.php"). jquery-1.8.3.js:8434
315026
600421
Does anyone know what's going on here ?
thanks,
J