I use below code to upload a Image with camera & gallery. I would like to encode it to Base64 to save offline.I can't see method, how to modify my code to convert Image uri in Base64.
import PhotoUpload from 'react-native-photo-upload'
const [ image, setImage ] = useState( false )
//const [agree, setAgree] = useState(false);
const [ teacherNameActive, setTeachersNameActive ] = useState( false )
return (
<>
<LinearGradient
colors={ [ '#FFFF', '#FFFF' ] }
style={ styles.linearGradient }>
<Text style={ styles.ScreenTitle }>Registration</Text>
<ScrollView>
<View style={ {
alignSelf: 'center',
backgroundColor: '#90C9C6',
width: 120,
height: 120,
borderRadius: 75
} }>
<PhotoUpload onPhotoSelect={ Avatar => {
if ( Avatar ) {
console.warn( 'Image string:', Avatar )
setImage( true )
}
} }
>
{ image ?
<Image
style={ styles.upload_Image_style }
/> : <>
<Image style={ styles.camera_image }
source={ require( "../../assets/profileIcons/Combined_Shape.png" ) }
//source={ imageSource }
/>
<Text style={ styles.camera_text }>Upload</Text>
<Text style={ styles.camera_text }>Photo</Text>
</>
}
</PhotoUpload>
</View>