热门标签 | 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)。它将正常工作。


推荐阅读
  • 利用决策树预测NBA比赛胜负的Python数据挖掘实践
    本文通过使用2013-14赛季NBA赛程与结果数据集以及2013年NBA排名数据,结合《Python数据挖掘入门与实践》一书中的方法,展示如何应用决策树算法进行比赛胜负预测。我们将详细讲解数据预处理、特征工程及模型评估等关键步骤。 ... [详细]
  • 本文详细介绍了如何在Kendo UI for jQuery的数据管理组件中,将行标题字段呈现为锚点(即可点击链接),帮助开发人员更高效地实现这一功能。通过具体的代码示例和解释,即使是新手也能轻松掌握。 ... [详细]
  • This guide provides a comprehensive step-by-step approach to successfully installing the MongoDB PHP driver on XAMPP for macOS, ensuring a smooth and efficient setup process. ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • 基因组浏览器中的Wig格式解析
    本文详细介绍了Wiggle(Wig)格式及其在基因组浏览器中的应用,涵盖variableStep和fixedStep两种主要格式的特点、适用场景及具体使用方法。同时,还提供了关于数据值和自定义参数的补充信息。 ... [详细]
  • 深入理解Redis的数据结构与对象系统
    本文详细探讨了Redis中的数据结构和对象系统的实现,包括字符串、列表、集合、哈希表和有序集合等五种核心对象类型,以及它们所使用的底层数据结构。通过分析源码和相关文献,帮助读者更好地理解Redis的设计原理。 ... [详细]
  • 本文将介绍网易NEC CSS框架的规范及其在实际项目中的应用。通过详细解析其分类和命名规则,探讨如何编写高效、可维护的CSS代码,并分享一些实用的学习心得。 ... [详细]
  • 在现代Web应用中,当用户滚动到页面底部时,自动加载更多内容的功能变得越来越普遍。这种无刷新加载技术不仅提升了用户体验,还优化了页面性能。本文将探讨如何实现这一功能,并介绍一些实际应用案例。 ... [详细]
  • Python处理Word文档的高效技巧
    本文详细介绍了如何使用Python处理Word文档,涵盖从基础操作到高级功能的各种技巧。我们将探讨如何生成文档、定义样式、提取表格数据以及处理超链接和图片等内容。 ... [详细]
  • 基于Node.js、Express、MongoDB和Socket.io的实时聊天应用开发
    本文详细介绍了使用Node.js、Express、MongoDB和Socket.io构建的实时聊天应用程序。涵盖项目结构、技术栈选择及关键依赖项的配置。 ... [详细]
  • 离线安装Grafana Cloudera Manager插件并监控CDH集群
    本文详细介绍如何离线安装Cloudera Manager (CM) 插件,并通过Grafana监控CDH集群的健康状况和资源使用情况。该插件利用CM提供的API接口进行数据获取和展示。 ... [详细]
  • 本文介绍如何在Windows Forms应用程序中使用C#实现DataGridView的多列排序功能,包括升序和降序排序。 ... [详细]
  • 利用 Jest 和 Supertest 实现接口测试的全面指南
    本文深入探讨了如何使用 Jest 和 Supertest 进行接口测试,通过实际案例详细解析了测试环境的搭建、测试用例的编写以及异步测试的处理方法。 ... [详细]
  • 计算机网络复习:第五章 网络层控制平面
    本文探讨了网络层的控制平面,包括转发和路由选择的基本原理。转发在数据平面上实现,通过配置路由器中的转发表完成;而路由选择则在控制平面上进行,涉及路由器中路由表的配置与更新。此外,文章还介绍了ICMP协议、两种控制平面的实现方法、路由选择算法及其分类等内容。 ... [详细]
  • 开发笔记:Python:GUI之tkinter学习笔记1控件的介绍及使用
    开发笔记:Python:GUI之tkinter学习笔记1控件的介绍及使用 ... [详细]
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社区 版权所有