ImagePicker android returns invalid base64 string with line breaks
See original GitHub issueHello guys!
I got a problem with the ImagePicker and the base64 option.
This is the code :
ImagePicker.launchImageLibraryAsync({mediaTypes: 'Images', allowsEditing: true, base64: true}) .then(source =>{console.log('source', source) if(!source.cancelled){ this.setState({source}) } });
When I use an Iphone (ios9 4S), the console log of the result is :
I can perfectly send this to my backend (I use Intervention with PHP) and everything is fine.
But with android, I got this :
We see the string is very different than the first one. And when I pass this to my backend, Intervention gives me an Exception “Image source not readable”.
I tried to process the base64 string result but with no success.
I repeat, everything is fine with IOS.
The base64 result of the ImagePicker is not good with android.
My problem came from only the base64 result.
Thanks for your answer!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:10 (2 by maintainers)
Follow @aalices tip, just remove the new lines with something like:
base64image = base64image.replace(/(?:\r\n|\r|\n)/g, '');
I think it is a separate problem. Will this work if you remove new line symbols from the string?