在nodejs中将文件附加到zip [英] Appending file to zip in nodejs

查看:32
本文介绍了在nodejs中将文件附加到zip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,您可以在其中编辑文件,它应该将编辑后的文件附加到 zip 存档并使其可下载.它应该是跨平台的(Windows 和 Linux).

I'm making an application in which you edit a file, and it should append the edited file to zip archive and make it downloadable. It should be cross platform (Windows and Linux).

我的目标是以编程方式生成编辑后的文件并将其附加到静态存档(始终相同,大约 3-4MB,但大约 40-50 个文件).

My goal is to programmatically generate the edited file and append it to static archive (which is always the same, around 3-4MBs, but around 40-50 files).

我查看了以下关于如何在 node.js 中压缩档案的帖子,但是 Eliseo Soto 的回答 取决于操作系统.

I've looked at the following post on how to zip archives in node.js, however the answer by Eliseo Soto is OS dependent.

我还找到了 daraosn/node-zip,但据我了解,它无法将文件附加到存档中,而无需重新制作.

I've also found daraosn/node-zip, but as I understood it's not able to append a file to the archive, without remaking it.

关于如何在不为每个请求从头开始重建整个存档的情况下完成我的目标的任何建议?

Any suggestions on how I can complete my goal without rebuilding the whole archive from scratch for each request?

推荐答案

node-zip 正在使用 JSZip.根据 JSZip 文档,在您的情况下不会重新创建存档.(如果 zip 文件存在,则将文件添加到其中).

node-zip is using JSZip. According to JSZip documentation, the archive is not recreated in yout case. (if the zip file exists, the files are added to it).

这篇关于在nodejs中将文件附加到zip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆