Node.js
Node.js
Unzip Text File to String
See more Zip Examples
Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var zip = new chilkat.Zip();
success = zip.OpenZip("qa_data/zips/EC16100.zip");
if (success == false) {
console.log(zip.LastErrorText);
return;
}
// Get the 1st file in the .zip
var entry = new chilkat.ZipEntry();
success = zip.EntryAt(0,entry);
if (success == false) {
console.log(zip.LastErrorText);
return;
}
var fileContents = entry.UnzipToString(0,"utf-8");
console.log(fileContents);
}
chilkatExample();