Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to send file stream with file name and file extension using NodeJS

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).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!