Sample code for 30+ languages & platforms
React Native

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat React Native Downloads

React Native
import { BinData } from '@chilkat/react-native'

function chilkatExample() {
  const bd = new BinData();

  try {
    bd.loadFile('qa_data/jpg/starfish.jpg');
  } catch {
    console.log('Failed to load file.');
    return;
  }

  console.log(bd.getEncoded('base64'));

  // If you want mult-line base64:
  console.log('--');
  console.log(bd.getEncoded('base64_mime'));

  // If you want hex..
  console.log('--');
  console.log(bd.getEncoded('hex'));

  // etc..
}