【发布时间】:2018-07-31 01:24:09
【问题描述】:
我有一个 nodejs 微服务,我在其中 zip 一个文件夹,其中包含由代码创建的 3 个文件。
现在,当我的服务收到 curl request 时,我需要将此 zip 文件作为 response 发送。我通读了类似的问题,但他们建议如何在客户端下载,不知道如何在这里使用它们。
我的nodejs代码是:
var zipper = require('zip-local');
app.post("/checkFunc", function(req, res) {
zipper.sync.zip("./finalFiles").compress().save("pack.zip");
// so now the zip is created and stored at pack.zip
console.log("Hello);
res.writeHead(200, { 'Content-Type': 'application/octet-stream' });
//res.send(a); //not sure how to send the zip file, if I know the path of the zip file.
});
【问题讨论】: