I'm using nodejs to send file streams to express response
var fileReadStream = fs.createReadStream(filePath);
fileReadStream.pipe(res);
The problem is, on the front-end, the file is downloadable only with the "download", and without extension. And this makes the file unable to use (as no extension).
CodePudding user response:
please add this header before sending the response(replace the filename according your need):
var fileReadStream = fs.createReadStream(filePath);
res.setHeader('Content-disposition', 'attachment; filename=YOUR_FILE.EXTENSION');
fileReadStream.pipe(res);