SnappFr / react-native-image-base64

Simple react native library to convert an image to a base64 string 🌄
MIT License
49 stars 28 forks source link

In IOS, image is not getting converted to base64 #6

Open purvotara opened 6 years ago

purvotara commented 6 years ago

Hi,

Thanks a lot for the wonderful work. In the android, conversion is working fine(Can you please add the permission check, if the read external storage is not given), but in the IOS conversion is not at happening. It's giving data as undefined. I mean base64String is undefined in IOS.

 imgToBase64.getBase64String(images[random].uri)
          .then(base64String => {

            console.log(base64String)
            this.navigateToResult(shareImageBase64);
          })
          .catch(err => console.log("Error in ImgToBase64", err));
      })

Could you please help in solving the issue.

Regards, Sharath

gilshaan commented 4 years ago

Same problem here in react-native version 0.60.2 Showing error: setUpDeveloperTools.js:73 Possible Unhandled Promise Rejection (id: 0): TypeError: Cannot read property 'getBase64String' of undefined TypeError: Cannot read property 'getBase64String' of undefined

gilshaan commented 4 years ago

I used another package: react-native-fs import RNFS from 'react-native-fs'; var data = await RNFS.readFile( "file://path-to-file", 'base64').then(res => { return res }); This works fine.

micnguyen commented 4 years ago

@gilshaan While that does work, it is a very heavy library to import if you simply want a base64 image.

@purvotara Have you got a reproduction step with a supplied image?

TaraSinghDanu commented 4 years ago

I used another package: react-native-fs import RNFS from 'react-native-fs'; var data = await RNFS.readFile( "file://path-to-file", 'base64').then(res => { return res }); This works fine.

How to use with https url.Its not working.