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

109
Views
Send file as buffer
const resp = await client.render(data);
const Writable = require('stream').Writable;
var buffer = [];
const myWritable = new Writable({
 write(chunk, encoding, callback) {
   console.log(encoding);
  buffer += chunk;
   callback();
 },
 });
myWritable.on('finish', () => {
 res.writeHead(200, {
    'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
   'Content-Disposition': `inline; filename=Non Billed Jobs.xlsx`,
   });
   res.end(buffer);
 });
resp.pipe(myWritable);

Why doesn’t this download the file? Trying to download something from jsreport but if I log buffer, it gives me strange characters

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

0

As suggested by Aneesh, returning a buffer would be ideal

 res.set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 res.set('Content-Disposition', 'inline; filename=Non Billed Jobs.xlsx');
 res.send(new Buffer(BUFFER_DATA, 'base64');

You could also use the Buffer.from() function instead.

I hope it helped!

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!