将文件追加到zip中的js [英] Appending file to zip in nodejs

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

问题描述

我正在制作一个用于编辑文件的应用程序,它应将编辑后的文件附加到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).

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

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