热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

将多个文件导入到zip文件中-Pipemultiplefilesintoazipfile

IhaveseveralfilesinaGridFSDocumentStoreandwhatIdliketodoistopipethisdataintoa

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.

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

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?

现在我的问题是如何在zip文件中给这些文件一个有效的文件名。我想我需要模拟/伪造一个包含文件名的文件头?

Any help is appreciated!

任何帮助都是赞赏!

Thanks

谢谢

1 个解决方案

#1


4  

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

我在用Node编写zip文件时遇到了问题。js不久前。我最后做了一些类似于node.js中的Zip归档文件中描述的事情

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.
  • 不要尝试使用节点存档。即使描述说它允许创建zip文件,当我读源代码的时候(因为文档是不存在的)我意识到那只是一个谎言。它只公开读取方法。
  • 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.
  • 通过生成进程来使用zip(如提供的链接中推荐的)似乎是最好的方法。可以使用的方法是将文件复制到本地文件夹中,然后调用zip命令,然后删除文件。
  • 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...).
  • 另一种选择似乎还可以,就是使用zipper (https://github.com/rubenv/zipper),不过最好还是使用npm。我之所以不希望使用它是因为它没有那么大的灵活性,它似乎是在一天内完成的,而且自从第一次提交之后它就没有被修改过,所以我不确定它是否会得到维护(当然,您可以用它来进行维护)。

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.

我发誓,我有一个完全免费的周末,没有工作,我会写一个该死的模块,这样做尽可能完整。没有这样做是愚蠢的,也不应该有那么多的挣扎。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.

编辑:不确定它以前是否存在,但是现在我使用了node-compress模块(也使用gzippo)。它将正常工作。


推荐阅读
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • 如何用Matlab快速画出带有3D渲染效果的复杂曲面
    简要地介绍了一下如何用Matlab快速画出带有3D渲染效果的复杂曲面图,包括三维曲面绘制、光线、材质、着色等等控制,以及如何 ... [详细]
  • mongoDB高可用集群环境搭建
    2019独角兽企业重金招聘Python工程师标准在生产环境下,部署一台mongodb服务的话,会存在以下问题:单点问题生产环境是一个 ... [详细]
  • 导入onImport:function(button,e,eOpts){varmMainGridExt.getCmp(storeMainGrid);varmSelectionsmM ... [详细]
  • vue使用
    关键词: ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文介绍了PhysioNet网站提供的生理信号处理工具箱WFDB Toolbox for Matlab的安装和使用方法。通过下载并添加到Matlab路径中或直接在Matlab中输入相关内容,即可完成安装。该工具箱提供了一系列函数,可以方便地处理生理信号数据。详细的安装和使用方法可以参考本文内容。 ... [详细]
  • 本文介绍了前端人员必须知道的三个问题,即前端都做哪些事、前端都需要哪些技术,以及前端的发展阶段。初级阶段包括HTML、CSS、JavaScript和jQuery的基础知识。进阶阶段涵盖了面向对象编程、响应式设计、Ajax、HTML5等新兴技术。高级阶段包括架构基础、模块化开发、预编译和前沿规范等内容。此外,还介绍了一些后端服务,如Node.js。 ... [详细]
  • Node.js学习笔记(一)package.json及cnpm
    本文介绍了Node.js中包的概念,以及如何使用包来统一管理具有相互依赖关系的模块。同时还介绍了NPM(Node Package Manager)的基本介绍和使用方法,以及如何通过NPM下载第三方模块。 ... [详细]
  • node.jsurlsearchparamsAPI哎哎哎 ... [详细]
  • 程序员如何选择机械键盘轴体?红轴和茶轴对比
    本文介绍了程序员如何选择机械键盘轴体,特别是红轴和茶轴的对比。同时还介绍了U盘安装Linux镜像的步骤,以及在Linux系统中安装软件的命令行操作。此外,还介绍了nodejs和npm的安装方法,以及在VSCode中安装和配置常用插件的方法。最后,还介绍了如何在GitHub上配置SSH密钥和git的基本配置。 ... [详细]
  • Node.js详细安装及环境配置
    1、下载安装根据自己电脑系统及位数选择,我这里选择windows64位.msi格式安装包(官网:https:odejs.orgzh-cndownload).msi和.zip格式区别 ... [详细]
  • **************************************************************** ... [详细]
  • 关于学extjs已经了解基本了的信息
    本文目录一览:1、学习extJS之前,应该具备什么基础 ... [详细]
author-avatar
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有