A React Native Module that takes an image's asset-library:// uri and returns base64:
npm install --save react-native-asset-library-to-base64- In the XCode's "Project navigator", right click on your project's Libraries folder ➜
Add Files to <...> - Go to
node_modules➜react-native-asset-library-to-base64➜ios➜ selectAssetLibraryToBase64.m - Make sure
AssetLibraryToBase64.mis listed under 'Compile Sources' in your project's 'Build Phases' tab - Compile and have fun
- In your React Native javascript code, bring in the native module:
var ReadImageData = require('NativeModules').ReadImageData;- Use it like so:
// uri is link to asset-library://
ReadImageData.readImage(uri, (imageBase64) => {
console.log(imageBase64);
});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.