Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

Unzip Files to Byte Array

See more Zip Examples

Demonstrates how to unzip each file contained in a .zip to an in-memory byte array.

Chilkat React Native Downloads

React Native
import { Zip, ZipEntry } from '@chilkat/react-native'

async function chilkatExample() {
  // This example assumes 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/test.zip');
  } catch {
    console.log(zip.lastErrorText);
    return;
  }

  // Iterate of each entry in the zip.
  // An entry can be a file or directory entry.  For each file, unzip to a byte array.
  const numEntries = zip.numEntries;
  console.log(`NumEntries = ${numEntries}`);

  const entry = new ZipEntry();
  let i = 0;
  while (i < numEntries) {
    zip.entryAt(i, entry);
    if (!entry.isDirectory) {
      const fileData = await entry.inflateAsync();
      // Do whatever you wish with the file data...
    }

    i++;
  }

  zip.closeZip();

  console.log('Finished.');
}