Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda