React Native Requires Chilkat v11.0.0+
React Native
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 React Native Downloads
import { Zip, ZipEntry } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const zip = new Zip();
try {
await zip.openZipAsync('qa_data/zips/EC16100.zip');
} catch {
console.log(zip.lastErrorText);
return;
}
// Get the 1st file in the .zip
const entry = new ZipEntry();
try {
zip.entryAt(0, entry);
} catch {
console.log(zip.lastErrorText);
return;
}
const fileContents = await entry.unzipToStringAsync(0, 'utf-8');
console.log(fileContents);
}