According to docs https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options
fs.createReadStream() can accept Buffer as first argument
my node code:
Creating a Readable Stream From Buffer.
You can easily create a Readable Stream from a Buffer, however using fs.createReadStream() does indeed require first writing it to a file path.
Using stream.Duplex()
Example:
const {Duplex} = require('stream'); // Native Node Module
function bufferToStream(myBuuffer) {
let tmp = new Duplex();
tmp.push(myBuuffer);
tmp.push(null);
return tmp;
}
const myReadableStream = bufferToStream(your_buffer);
// use myReadableStream anywhere you would use a stream
// created using fs.createReadStream('some_path.ext');
// For really large streams, you may want to pipe the buffer into the Duplex.