How to extract one file from zipped directory? Zlib doesn't have any file browsing features, neither does extract-zip So I don't know what to use.
You can use EvanOxfeld/node-unzip
parse zip file contents:
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()
}
})
[ Example archive ]