jaswude-adm-zip
v0.5.15
Published
基于adm-zip 0.5.9,解决解压文件名中文乱码问题
Downloads
17
Maintainers
Readme
Before
- 基于adm-zip 0.5.9,解决解压文件名中文乱码问题,更多文档参考adm-zip
- 此包依赖于iconv-lite转换编码格式
- 支持ts环境开发
- 此包不会弃用或删除
Version Description
- 0.5.9,基于adm-zip 0.5.9,新增依赖iconv-lite改变buffer编码为GBK实现中文输出
- 0.5.10~14,废弃版本,一直在尝试上传ts文件纳闷为什么上传不了,原来是pkg.json的"files"属性没包含...
- 0.5.15,新增index.d.ts以支持ts工作环境下开发
--以下是adm-zip原文档,截至2022-02-15--
Installation
With npm do:
$ npm install adm-zip
What is it good for?
The library allows you to:
- decompress zip files directly to disk or in memory buffers
- compress files and store them to disk in .zip format or in compressed buffers
- update content of/add new/delete files from an existing .zip
Dependencies
There are no other nodeJS libraries that ADM-ZIP is dependent of
Examples
Basic usage
var AdmZip = require("adm-zip");
// reading archives
var zip = new AdmZip("./my_file.zip");
var zipEntries = zip.getEntries(); // an array of ZipEntry records
zipEntries.forEach(function (zipEntry) {
console.log(zipEntry.toString()); // outputs zip entries information
if (zipEntry.entryName == "my_file.txt") {
console.log(zipEntry.getData().toString("utf8"));
}
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);
// creating archives
var zip = new AdmZip();
// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");
// ... more examples in the wiki
For more detailed information please check out the wiki.