首页 文章

使用react-native-image-picker将图像上传到firebase

提问于
浏览
0

我一直在尝试使用firebase,React Native和react-native-image-picker上传图像 .

我从图像选择器获得的数据是base64格式,我不知道如何将其实际上传到我的firebase存储,因为当我执行以下行时:

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

之后什么都没有执行 . 即使我立即发出警报 . 我的«file»变量包含: 'data:image/jpeg;base64,' + response.data

我也尝试过只放置response.data,但它没有用 .

1 回答

  • 2

    从我上次阅读here开始,Firebase不支持从 react-native 上传图像作为二进制文件 . 但是,您可以将base64编码的图像直接存储在firebase中 . 这就像在firebase中存储任何其他字符串一样 . 虽然将图像直接存储在firebase上,但是有一个限制 less than 10 MB .

相关问题