Skip to content

wootwoot1234/react-native-asset-library-to-base64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-asset-library-to-base64

A React Native Module that takes an image's asset-library:// uri and returns base64:

Install

iOS

  1. npm install --save react-native-asset-library-to-base64
  2. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...>
  3. Go to node_modulesreact-native-asset-library-to-base64ios ➜ select AssetLibraryToBase64.m
  4. Make sure AssetLibraryToBase64.m is listed under 'Compile Sources' in your project's 'Build Phases' tab
  5. Compile and have fun

Usage

  1. In your React Native javascript code, bring in the native module:
var ReadImageData = require('NativeModules').ReadImageData;
  1. Use it like so:
// uri is link to asset-library://
ReadImageData.readImage(uri, (imageBase64) => {
console.log(imageBase64);
});

Source

This code was copied from https://github.com/scottdixon/react-native-upload-from-camera-roll/blob/master/RCTCustom.m and https://medium.com/@scottdixon/react-native-creating-a-custom-module-to-upload-camera-roll-images-7a3c26bac309#.xckz6wr87. I just took the example and turned it into a module for ease of use.

About

React Native Module that takes an image's asset-library:// uri and returns base64

Resources

License

Stars

Watchers

Forks

Packages

No packages published