Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs send download file from buffer

var stream = require('stream');
//...
app.get('/download', function(request, response){
  //...
  var fileContents = Buffer.from(fileData, "base64");
  
  var readStream = new stream.PassThrough();
  readStream.end(fileContents);

  response.set('Content-disposition', 'attachment; filename=' + fileName);
  response.set('Content-Type', 'text/plain');

  readStream.pipe(response);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: search with multiple field in node js mongodb 
Javascript :: TypeError: path must be absolute or specify root to res.sendFile 
Javascript :: javascript find unique values in array of objects 
Javascript :: TypeError: this.setState is not a function 
Javascript :: map in js 
Javascript :: sails disable grunt 
Javascript :: node http2 post 
Javascript :: how to create a component in angular using terminal 
Javascript :: make file from array save js 
Javascript :: bootstrap carousel dynamic height jquery 
Javascript :: apply() js 
Javascript :: javascript loop last index 
Javascript :: how to append element in array angular 
Javascript :: knex.raw postgres how to add multiple parameters 
Javascript :: how to click on alret dialog with pupeteer 
Javascript :: TypeError: fxn.call is not a function 
Javascript :: change base js 
Javascript :: mariadb javascript 
Javascript :: change cover photo with javascript 
Javascript :: react native websocket useSession 
Javascript :: angular 8 remove cookies 
Javascript :: can i select multiple classes and give function to them at once but different in js 
Javascript :: convert svg to react component 
Javascript :: jsfuck 
Javascript :: image downloader extension in nodejs 
Javascript :: window.history 
Javascript :: flutter local json storage 
Javascript :: jquery slick drag goes back 
Javascript :: fs readfile encoding 
Javascript :: Function.prototype.bind polyfill 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =