Sample code for 30+ languages & platforms
React Native

Ungzip Base64 String

See more Gzip Examples

Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.

Chilkat React Native Downloads

React Native
import { BinData, Gzip } 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 gzip = new Gzip();

  const gzipBase64 = 'H4sIAAAAAAAE ... X6aZjXO3EwAA';

  const bd = new BinData();
  bd.appendEncoded(gzipBase64, 'base64');

  try {
    await gzip.uncompressBdAsync(bd);
  } catch {
    console.log(gzip.lastErrorText);
    return;
  }

  const strXml = bd.getString('utf-8');
  console.log('XML:');
  console.log(strXml);
}