I need to save a response to a file. The response is a zip file returned from a server which is recieved as a blob. I need to save to blob as a zip file on my local machine. The application itself is Electron, and the file needs to be stored in the background (without bothering the user). Filetype is zip ( and needs to be unzipped after this.
const writer = fs.createWriteStream(path.join(dir, 'files.zip'));
writer.on('pipe', (src) => {
console.log('Something is piping into the writer.');
});
writer.end('This is the end\n');
writer.on('finish', () => {
console.log('All writes are now complete.');
});
writer.pipe(new Blob([response.data]));
Best i can do gives a 1kb corrupt file. I have read the node docs, but i can't get it to work.
ANY response is greatly appreciated, and please elaborate if you can. I feel like i need to use some type of buffer.