如何从大型 ZIP 存档中提取单个文件
How to extract a single file from a large ZIP archive
如何从压缩目录中提取一个文件?
Zlib 没有任何文件浏览功能,extract-zip 也没有
所以我不知道该用什么。
您可以使用EvanOxfeld/node-unzip
解析zip文件内容:
var fs = require('fs')
var unzip = require('unzip')
var path = require('path')
var mkdir = require('mkdirp')
fs.createReadStream('./archive.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
var fileName = entry.path
var type = entry.type
if (type==='File' && fileName === 'dir/fileInsideDir.txt') {
var fullPath = __dirname + '/output/' + path.dirname( fileName )
fileName = path.basename( fileName )
mkdir.sync(fullPath)
entry.pipe(fs.createWriteStream( fullPath + '/' + fileName ))
} else {
entry.autodrain()
}
})
如何从压缩目录中提取一个文件? Zlib 没有任何文件浏览功能,extract-zip 也没有 所以我不知道该用什么。
您可以使用EvanOxfeld/node-unzip
解析zip文件内容:
var fs = require('fs')
var unzip = require('unzip')
var path = require('path')
var mkdir = require('mkdirp')
fs.createReadStream('./archive.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
var fileName = entry.path
var type = entry.type
if (type==='File' && fileName === 'dir/fileInsideDir.txt') {
var fullPath = __dirname + '/output/' + path.dirname( fileName )
fileName = path.basename( fileName )
mkdir.sync(fullPath)
entry.pipe(fs.createWriteStream( fullPath + '/' + fileName ))
} else {
entry.autodrain()
}
})