How to use the expo-asset-utils.base64forImageUriAsync function in expo-asset-utils

To help you get started, we’ve selected a few expo-asset-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-asset-utils / example / _App.js View on Github external
asset: assetLibraryImage,
        example: `const { edges } = await CameraRoll.getPhotos({ first: 1 });
const asset = edges.map(({ node: { image } }) => image.uri)[0];
AssetUtils.resolveAsync(asset);`,
      },
    };

    let parsed = {};
    const keys = Object.keys(assets);
    for (const key of keys) {
      const { asset: res, ...props } = assets[key];
      const asset = await AssetUtils.resolveAsync(res);
      parsed[key] = { asset, ...props };
    }

    const base64 = await AssetUtils.base64forImageUriAsync(remoteImageUri);
    const pngPrefix = 'data:image/png;base64,';
    parsed['base64'] = {
      title: 'Base64 Encoded',
      description:
        'From "ImageStore" this is a large string with a prefix of "data:image/png;base64,"',
      asset: { uri: pngPrefix + base64.data },
      example: `const { data } = await AssetUtils.base64forImageUriAsync(remoteImageUri);
const base64 = '${pngPrefix}' + data;`,
    };

    this.setState({ images: parsed });
  }