Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how can i convert image uri to base64?

$
0
0

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 incoding ?

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();        },      });    });  };`

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>