I needed to Un-Zip a folder in node js.
I could easily get to the list of fileNames, but could only do the following to extract the file content.
String.fromCharCode.apply(null, zip.files[fileName]._data.compressedContent)
I am sure this is not the right approach, but could find nothing in the documentation to advise me to the correct method.
I'm trying to find an example for extracting all contents of a zip to a folder too. All examples stop after
zip.loadAsync(data)
.then(content => {
// list all the files
console.log(Object.keys(content.files));
// what next?
})
Just for future use, after that you can read the content of each file by the help of async:
http://stuk.github.io/jszip/documentation/api_zipobject/async.html
like this:
// Closure to capture the file information.
function handleFile(f) {
JSZip.loadAsync(f)
.then(function(zip) {
zip.forEach(function (relativePath, zipEntry) {
zipEntry.async("blob") .then(function (content) { fileReader.readAsArrayBuffer(content); });
});
}, function (e) {
alert("Error reading " + f.name + ": " + e.message);
});
}
@pesarkhobeee The URL seems to be broken, changing it to a https URL seems to work:
http://stuk.github.io/jszip/documentation/api_zipobject/async.html
How can we extract files from .zip using jszip?
I want to open those files in different application...
Most helpful comment
Just for future use, after that you can read the content of each file by the help of async:
http://stuk.github.io/jszip/documentation/api_zipobject/async.html
like this: