Upload image to firebase using react-native-image-

2020-08-04 10:05发布

I’ve been trying to upload an image using firebase, React Native and react-native-image-picker.

The data I get from the image picker is in base64 format and I don’t know how to actually upload it to my firebase storage because when I execute the following line :

var imageRef = storageRef.child("images/usersImages/" + global.userID + ".jpg")
uploadTask = imageRef.put(global.imageToUpload)

Nothing is executed after. Even if I put an alert right after. My « file » variable contains that : 'data:image/jpeg;base64,' + response.data

I’ve also tried to put only the response.data but it’s not working.

1条回答
你好瞎i
2楼-- · 2020-08-04 10:38

From what I read last here, Firebase doesn't support uploading images as binaries from react-native. However, you can store the base64 encoded image directly in firebase. It would be like storing any other string in firebase. There is a limit of less than 10 MB though while storing image directly on firebase like this.

查看更多
登录 后发表回答