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

Asked

Viewed 481 times

0

I am using the React-Native-image-Picker component to capture an image that must be saved in firebase. I’m using the following code:

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

Response.data returns a string Base64, but firebase returns the error shown in the image below:

Erro ao fazer upload para o firebase

1 answer

0


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

According to this post, try using this function before moving to Storage

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.