I am using react-native-image-picker along with react-native-photo-editor ..
photo editor returns uri of the edited image while my api supports base64, is there a way I can convert the edited image uri to base64 encoding ?
this is my code below
const handleOnUploadFromLibrary = () => {
launchImageLibrary(libraryOptions, (response: ImagePickerResponse) => {
if (response.assets) {
let assets = response.assets[0];
let imagePathMinusExtention = assets.uri?.replace('file://', '');
setImagePickerAsset({...assets, uri: imagePathMinusExtention});
}
PhotoEditor.Edit({
path: imagePickerAsset?.uri || '',
onDone: (path) => {
console.log('donee::::');
let extention = "file://";
let imagePathPlusExtention = extention.concat(`${path}`);
setImagePickerAsset({...imagePickerAsset, uri: imagePathPlusExtention});
var data: UsedAttachment = {
fileType: imagePickerAsset?.type,
fileName: imagePickerAsset?.fileName,
refId: visit.draftAppRequestId,
refTypeId: '5', //draftx
title: imagePickerAsset?.fileName,
mimeType: imagePickerAsset?.type,
modelMapperKey: '',
files: [imagePickerAsset?.uri],
};
callUploadAttachment({data});
hideDialog();
},
onCancel: () => {
console.log('Cancel ::: ');
hideDialog();
},
});
});
};