How does nodejs push files to the browser

  node.js, question

Node generated a buffer for a file, which passed throughwriteFile()Ok, this buffer is output to the server. I want to generate this file and then it will not exist on the server, but will be pushed to the browser and downloaded directly. what’s the matter?

res.set('Content-Type','application/force-download');
 res.set('Content-Disposition','attachment;  filename=aa.txt');
 /*
 //read files directly
 var fReadStream = fs.createReadStream(filePath, {
 encoding : 'binary',
 bufferSize : 1024 * 1024
 });
 */
 //Reuse the buffer you got before needs to refer to [stream-buffer] (https://www.npmjs.com/package/stream-buffers)
 var myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
 frequency: 10       // in milliseconds.
 chunkSize: 2048     // in bytes.
 });
 
 myReadableStreamBuffer.put(aBuffer);
 myReadableStreamBuffer.on('data', function(chunk) {
 res.write(chunk, 'binary');
 });
 myReadableStreamBuffer.on('end', function() {
 res.end();
 });