[英]Zip file download
I have something like that: 我有这样的事情:
function DownLoadZip(response){
console.log(response.zipFile); // result of console log - example.zip
res.writeHead(200, {
'Content-Type': 'application/zip',
'Content-Length': stat.size
});
};
Question: How can I give to client completed zip file. 问题:如何给客户完整的zip文件。 This file comes with response. 该文件带有响应。 Maybe I forgot some headers or that is something else. 也许我忘记了一些标题,或者别的。 Any ideas? 有任何想法吗? Thanks for attention and have a nice day! 感谢您的关注,祝您有美好的一天!
In case response.zipFile
is a path: fs.createReadStream(response.zipFile).pipe(res);
如果response.zipFile
是路径: fs.createReadStream(response.zipFile).pipe(res);
If response
is a stream: response.pipe(res);
如果response
是一个流: response.pipe(res);
Maybe it helps somebody! 也许对某人有帮助! I have forgotten type: 我忘记了键入:
res.send();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.