node-archiver
node-archiver copied to clipboard
Can I get the Buffer from fs.createWriteStream()?
I have simple question - Can I get the Buffer from fs.createWriteStream()?
In my case I use archiver NPM module wich may create archives from Buffer. When this module end work with method archive.finalize() I may get result from archive.pipe(stream). I want have Buffer from fs.createWriteStream() wich I may send to res.send() Express method.
let archive = archiver("zip", {
zlib: { level: 9 } // Sets the compression level.
});
const stream = fs.createWriteStream(
"./src/backend/api/test.zip"
);
archive.pipe(stream);
archive.append(buffer, { name: "test.csv" });
archive.finalize();
Thank for you answer! And sorry for realy bad English.
Hello there, not an expert but here is what I did
const fs = require("fs");
// the rest of the code
res.send(fs.readFileSync(zipPath))