Sample code for 30+ languages & platforms
React Native

Decompress Bytes

See more Compression Examples

Demonstrates how to decompress binary data.

Chilkat React Native Downloads

React Native
import { Compression, FileAccess } 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.

  // See this example to compress bytes: Compress Bytes

  const fac = new FileAccess();

  const compressedBytes = fac.readEntireFile('qa_data/compressed/compressedBmp.dat');
  if (!fac.lastMethodSuccess) {
    console.log(fac.lastErrorText);
    return;
  }

  const compress = new Compression();
  compress.algorithm = 'deflate';

  const decompressedBytes = await compress.decompressBytesAsync(compressedBytes);
  if (!compress.lastMethodSuccess) {
    console.log(compress.lastErrorText);
    return;
  }

  try {
    fac.writeEntireFile('qa_output/decompressed.bmp', decompressedBytes);
  } catch {
    console.log(fac.lastErrorText);
    return;
  }
}