I am trying to upload images from cameraRoll
. Thing is the cameraRoll
component returns content:// URI rather than an actual file path. For uploading the image I need a file path, is there any way to convert content:// URI to file URI? Thanks
I took the function submitted by @Madhukar Hebbar and made it into a React Native Node Module.
You can find it here: react-native-get-real-path
Thus to achieve what you want, you can use the above module in conjunction with react-native-fs
You can then do something like this when you want to upload the selected image from Camera Roll:
RNGRP.getRealPathFromURI(this.state.selectedImageUri).then(path =>
RNFS.readFile(path, 'base64').then(imageBase64 =>
this.props.actions.sendImageAsBase64(imageBase64)
)
)