Я пробовал этот код для отправки zip-ответа в заголовок, но что-то не хватает с моей стороны. В этом я получаю ответ, как показано на скриншоте
Вот мой код ..
const zipPath - './test.zip'; // I have a zip with 2 files inside it (password protected)
const stat = fs.statSync(zipPath);
res.setHeader('Content-Disposition', 'attachment; filename=devices.zip');
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Length', stat.size);
res.writeHead(200, {
'Content-Type': 'application/octet-stream',
'Content-Disposition': 'attachment; filename=test.zip',
'Content-Length': stat.size
});
let fileStream = fs.createReadStream(zipPath);
fileStream.pipe(res);
res.end();