在 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
Unzip files with node.js on Windows
提问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 Buffer
s.
还提供了遍历 zip 条目和通过Buffer
s获取数据的方法。