Upload image to firebase using react-native-image-picker

試著忘記壹切 提交于 2020-01-02 00:24:09

问题


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:


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.



来源:https://stackoverflow.com/questions/38739002/upload-image-to-firebase-using-react-native-image-picker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!