NodeJS download file not working on IE
I've ran into a problem that seems very simple to me, but I can't for the
life of me figure it out. I have a simple NodeJS server that uses
ExpressJS that basically verifies an email and grants the user access to a
zip file. The problem is this works great on Chrome and Firefox but not on
IE until I open the F12 developer console. I've looked through all
documentation I came across on here and various other sites with no
mentions of similar problems.
My guess is some setting isn't enabled on IE, but I've verified I have
active scripting enabled, and lowered my security level. This problem is
happening for all my IE users and i'm hoping someone will have an answer
for me.
var stat = fs.statSync('myFile.zip');
res.writeHead(200, {
'Content-Type': 'application/octet-stream',
'Content-Length': stat.size,
'Content-disposition' : 'attachment; filename="myFile.zip'
});
console.log('Starting download: ' + 'myFile.zip' );
var stream = fs.createReadStream( 'myFile.zip', { bufferSize: 64 * 1024 });
stream.pipe(res);
//res.download( 'myFile.zip', "myFile.zip" );
As you can see I've tried both expressjs's res.download and stream.pipe
with the exact same results.
Thank you in Advance Adam
No comments:
Post a Comment