1. 首页
  2. 数据库
  3. 其它
  4. 大型ZIPs文件查看node stream zip.zip

大型ZIPs文件查看node stream zip.zip

上传者: 2021-04-24 06:18:22上传 ZIP文件 369KB 热度 11次
node-stream-zip 是查看和提取大型 ZIP 文件的 Node.js 库。特性:从不加载完整的归档到内存,一切都是通过块读取大型归档支持所有操作都是非阻塞,非同步 i/o快速初始化无依赖,无二进制组件内置 zlib 模块解压deflate, deflate64, sfx, macosx/windows 内置归档ZIP64 支持安装$ npm install node-stream-zip使用var StreamZip = require('node-stream-zip'); var zip = new StreamZip({ file: 'archive.zip', storeEntries: true }); zip.on('error', function(err) { /*handle*/ }); zip.on('ready', function() { console.log('Entries read: ' zip.entriesCount); // stream to stdout zip.stream('node/benchmark/net/tcp-raw-c2s.js', function(err, stm) { stm.pipe(process.stdout); }); // extract file zip.extract('node/benchmark/net/tcp-raw-c2s.js', './temp/', function(err) { console.log('Entry extracted'); }); // extract folder zip.extract('node/benchmark/', './temp/', function(err, count) { console.log('Extracted ' count ' entries'); }); // extract all zip.extract(null, './temp/', function(err, count) { console.log('Extracted ' count ' entries'); }); // read file as buffer in sync way var data = zip.entryDataSync('README.md'); }); zip.on('extract', function(entry, file) { console.log('Extracted ' entry.name ' to ' file); }); zip.on('entry', function(entry) { // called on load, when entry description has been read // you can already stream this entry, without waiting until all entry descriptions are read (suitable for very large archives) console.log('Read entry ', entry.name); });
下载地址
用户评论