javascript - putFile 不是函数
问题描述
我是 React Native 的新手,正在尝试为慈善机构创建一个应用程序。
尝试将使用相机拍摄的图像存储在 Firebase 存储中时遇到问题。
代码片段在下面,查看控制台日志,一切看起来都如我所料,也在下面。
我得到的错误是“imageRef.Putfile 不是函数”。
任何帮助将不胜感激。
控制台日志输出
ref, image, imageName breadalert-86646.appspot.com file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Frn-complete-guide-10d15822-a070-46a4-a2a0-98550f263c74/ImagePicker/8211188f-6bf4-4aaf-a3ba-e187b1e3707f.jpg CKhLXQlDUtUvKotCYQmJLmOeI1s247
getting storage ref of breadalert-86646.appspot.com
firebaseStorageRef is gs://breadalert-86646.appspot.com/
Image is gs://breadalert-86646.appspot.com/CKhLXQlDUtUvKotCYQmJLmOeI1s247
Image Path is file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Frn-complete-guide-10d15822-a070-46a4-a2a0-98550f263c74/ImagePicker/8211188f-6bf4-4aaf-a3ba-e187b1e3707f.jpg
代码片段
saveImage = (ref, image, imageName, onSuccess, onError) => {
console.log ('ref, image, imageName ' + ref + ' ' + image + ' ' + imageName);
console.log ('getting storage ref of ' + ref);
firebaseStorageRef = firebase.storage().ref();
console.log ('firebaseStorageRef is ' + firebaseStorageRef);
imageRef = firebaseStorageRef.child(imageName);
console.log ('Image is ' + imageRef);
console.log ('Image Path is ' + image);
imageRef.putFile (image.path, {contentType: 'image/jpeg'}).then(function(){
return imageRef.getDownloadURL();
}).then(function(url){
console.log ("Image url", {url:url});
onSuccess(url);
}).catch(function(error){
console.log ("Error while saving the image.. ", error);
onError(error);
});
}
解决方案
推荐阅读
- discord - 如何在 Discord.js 中制作按钮
- flutter - 以编程方式更改BottomNavigationBar Flutter上的选项卡并且不使用BottomNavigationBar的onTap?
- php - 使用正则表达式每隔两次出现分隔符拆分一个字符串
- python - 将对象转换为新类
- flutter - Flutter从列表中获取单个变量?
- spring - 在 Spring 中上传后更改视频文件(重新上传文件)
- javascript - 在反应中将文本与输入字段对齐
- sql - 插入脚本中的 SQL 提交
- html - Uncaught SyntaxError: Unexpected token '<' express typescript
- php - 会话数组在不同的机器上给出相同的结果,并且在指定时间后不会自行销毁