Image Upload with Firebase and React Native using RN Image-picker

0

I'm using the react-native-image-picker component to capture an image that should be saved in the firebase. I'm using the following code:

firebaseApp.storage().ref('/images/').child('teste') .putString(response.data, 'base64')

response.data returns a base64 string, but firebase returns the error shown in the image below:

    
asked by anonymous 30.06.2017 / 17:15

1 answer

0

Sometimes base64 files come with unnecessary space bars inserted by the plugin and / or framework that you are using. The Storage SDK is sensitive to these errors and can not perform some of its internal functions. To resolve this bug you need to remove these blanks.

Second this post, try using this function before moving to storage

function decodeFromBase64(input) {
 input = input.replace(/\s/g, '');
 return atob(input);
}
    
03.07.2017 / 22:04