将多个文件通过管道传输到一个 zip 文件中

发布于 2024-12-09 08:53:20 字数 201 浏览 2 评论 0原文

我在 GridFS 文档存储中有几个文件,我想做的是通过 NodeJS 中的 stdin 将这些数据传输到 zip 文件中。这样我最终会得到一个包含所有这些文件的 zip 文件。

现在我的问题是如何为文件提供有效的文件名在 zip 文件内。我想我需要模拟/伪造包含文件名的文件头?

任何帮助表示赞赏!

谢谢

I have several files in a GridFS Document Store and what I'd like to do is to pipe this data into a zip file via stdin in NodeJS. So that I will end up with a zip file containing all these files.

Now my question is how can I give the files a valid filename inside of the zip file. I think I need to emulate/fake a file header containing the filename?

Any help is appreciated!

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗忘曾经 2024-12-16 08:53:20

不久前,我在使用 Node.js 编写 zip 文件时遇到了问题。我最终做了类似于 Zip archives in node.js 中描述的

事情无法直接帮助您解决问题,但至少我希望我可以指出一些事情:

我发誓,有一天我有一个完整的空闲周末,没有工作,我会写一个该死的模块,尽可能完整地完成这件事。很愚蠢的是,没有,也不应该有那么多的挣扎。胡言乱语。

编辑:
不确定以前是否存在,但现在我一直在使用节点压缩模块(也使用 gzippo)。效果很好。

I had problems when writing zip files with Node.js not long ago. I ended up doing something similar to what is described in Zip archives in node.js

I can't help you directly with your problem, but at least I hope I can point out some things:

  • Don't try to use node-archive. Even if the description says it allows to create zip files, the moment I read the source code (since documentation is unexistant) I realized that's just a lie. It only exposes methods for reading.
  • Using zip by spawning a process, like recommended on the provided link, seems to be the best way. Something that would work is copying the files to a local folder with whatever name you desire and then calling the zip command, just to delete the files afterwards.
  • The other option, which seems ok, is to use zipper (https://github.com/rubenv/zipper, although better just use npm). The reason I'm not really wishing to use it is because there's not that much flexibility, it seems to have been done in a day and it hasn't been modified since the first commit, so I'm not sure it will receive maintenance (sure, you could just fork it...).

I swear the day I have an entire free weekend with no work I will write a freaking module that does this as complete as possible. It's silly that there isn't and it shouldn't be that much struggle. blablablarant.

Edit:
Not sure if it was there before, but now I've been using the node-compress module (also using gzippo). It works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文