问题标签 [yauzl]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
515 浏览

unzip - 如何使用yauzl解压到一个文件夹?

我正在尝试使用 yauzl 解压缩文件。但是,repo中的示例未显示如何解压缩到文件夹。它只是说:

有没有一种简单的方法可以将内容提取到文件夹中?

0 投票
0 回答
57 浏览

node.js - 使用yauzl时如何按文件名读取特定文件?

我必须从 zip 存档中提取文件,然后处理它。

问题是每个档案都有自己的清单文件,我必须检查它是否有效。如何首先检查清单文件并仅在其可用且有效时才进行处理?

0 投票
1 回答
677 浏览

node.js - NodeJS Yauzl - 将子文件夹提取到新的 zip

我有一个特定的用例,我找不到一个例子,到目前为止,尝试将不同的例子组合在一起对我来说并没有太大的收获。

我在 AWS 上的 Lambda 中使用 nodeJS 函数

我有一个缓冲区形式的 zipfile(只需使用 getObject 从 S3 读取)。zip 永远不会超过 10mb,因此可以在内存中执行它,并且可以避免使用流,并希望避免使用本地 tmp。

每个 zip 都有一些文件和文件夹,我想获取名为“src/”的文件夹中的所有文件。这对所有拉链都是一样的。这些文件不需要解压缩,我想将它们直接放入一个没有“src”子文件夹的新 zip - 所以只是新 zip 根目录上的“src”中的文件和文件夹,压缩后的任何文件夹src/ 应该保留它们的层次结构。

最终结果应该是输出 zip 的缓冲区。

任何帮助将非常感激。

0 投票
1 回答
27 浏览

node.js - yauzl callback parameter is undefined in one computer, works fine in another

I'm trying to do

when zipfile is supposed to be of type ZipFile

On one computer everything is fine, on the other one I keep getting undefined.

The only differences between the too is that I downloaded the yauzl module using npm install yauzl then copied the node_modules folder + the package.json & package-lock.json to the second computer (it's offline so I cant directly install onto it)

It never did any problems up until now, and when I tried copying the entire project back to the first computer from the second computer it works!

Any idea?

Pictures for references:

On the first computer (working one): enter image description here

On the second computer (not working one): enter image description here

PS The null on this picture is the options object and zipfile still shows up as undefined even with something in it.

0 投票
1 回答
78 浏览

javascript - 带有嵌套文件夹的 Zip 存档不会使用 yauzl 解压缩

我正在编写软件,其中包括使用 Dropbox API 下载 zip 存档,然后使用 yauzl 解压缩该存档。

从数据库存储和下载文件的方式通常以嵌套文件夹结尾,我需要保持这种方式。

但是,我的 yauzl 实现无法在保持嵌套文件夹结构的同时解压缩,如果存档中有嵌套文件夹,它根本不会解压缩。

这是我的解压缩函数,这是默认的 yauzl 示例,最后添加了本地文件写入。

删除if (/\/$/.test(entry.fileName))检查会将顶级文件夹视为文件,将其提取为没有文件扩展名和 0kb 大小。我想要它做的是提取包含子文件夹的存档(至少深度为 2,注意 zip 轰炸的风险)。

这可能使用yauzl吗?

0 投票
0 回答
20 浏览

javascript - 在 Javascript 中解压缩 3MF 文件

我是 javascript 新手,我想为我的项目完成解压缩 3mf 文件的任务。这是我正在尝试的以下代码。

我无法提取 3MF 文件中的文件。谁能建议我解决这个问题的方法?

0 投票
0 回答
6 浏览

node.js - 使用来自 yauzl 的流式传输的 Mongorestore 部分恢复

我正在尝试编写接收包含已保存 MongoDB 集合的 zip 文件的 Node 类,然后读取它yauzl并将这些集合恢复到本地 DB 数据集。收集档案是使用创建的mongodump,每个文件都有 filename <db-name>.<collection-name>.archive

这主要适用 - 对于小型集合,文件被读取和恢复。但是对于大型集合 (1GB) 数据,它只恢复一个 30 Mb 的块,然后继续到下一个文件。似乎在 CLI 中恢复大型档案时,档案以 30Mb 的块上传(您可以在终端中看到它,它会写入其进度)。当我运行以下代码时,在第一个块之后on('end')被调用并且读取流关闭。

任何想法这里缺少什么?