在 Windows 上使用 node.js 解压缩文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7645310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:11:48  来源:igfitidea点击:

Unzip files with node.js on Windows

windowsnode.jszipzlibunzip

提问by paperclip

What options are there to handle unzipping .zipfiles from within a Node.js script on Windows(XP)?

有哪些选项可以处理从Windows(XP)上的 Node.js 脚本中解压.zip文件?

I'm working with the latest (at present) node.js v0.5.8Windows node.exe.

我正在使用最新的(目前)node.js v0.5.8Windows node.exe

Suggestions welcome.

欢迎提出建议。

-P.

-P。

采纳答案by blockchaindev

Node provides support for the ZLIB library which should allow you to decompress a zip file using gzip: http://nodejs.org/docs/v0.5.8/api/zlib.html

Node 提供对 ZLIB 库的支持,它应该允许您使用 gzip 解压缩 zip 文件:http: //nodejs.org/docs/v0.5.8/api/zlib.html

回答by helios

I've found this zip library. It's very easy to install and use:

我找到了这个zip 库。安装和使用非常简单:

npm install zip
/* Only js dependencies, no local building needed */

from test.js

test.js

var z = require("zip");
var FS = require("fs");
var data = FS.readFileSync("test.zip")
var reader = z.Reader(data);
console.log(reader.toObject('utf-8'));

Provides also ways to iterate through the zip entries and getting data through Buffers.

还提供了遍历 zip 条目和通过Buffers获取数据的方法。

回答by Gopal Saini

ADM-ZIPis a pure JavaScript implementation for zip data compression for NodeJS.

ADM-ZIP是一个纯 JavaScript 实现,用于 NodeJS 的 zip 数据压缩。