问题描述
exports.zip = async function(req,res) {
var dirPath = path.resolve(__dirname,'../data/test.zip');
await res.zip({
files: [
{ content: 'this is a string',//options can refer to [http://archiverjs.com/zip-stream/ZipStream.html#entry](http://archiverjs.com/zip-stream/ZipStream.html#entry)
name: 'file-name',mode: 0755,comment: 'comment-for-the-file',date: new Date(),type: 'file' },{ path: path.join(dirPath,'test'),name: 'test' },//can be a file
],filename: 'test.zip'
});
我的路线是:
app.route('/zip').post(homeController.zip);
使用邮递员进行测试时,我得到了带有“另存为文件”选项的 zip 文件
在我的react前端,需要直接下载并保存API的响应文件。
我该怎么做? 谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)