如何将图像列表上传到Firebase存储并获取所有URL
我正在使用Firebase存储上传图像,然后将URL存储到Firebase DB中。 我正在使用它来上传图像列表,但是下面的代码在firebase V8中效果很好,但在版本9中却没有
export const multiImageUpload = async (path = "Products", imageFileList) => {
let imagesUrlArray = [];
let imageUrl = "";
// array of files
let arr = imageFileList.map((item) => {
return item.originFileObj;
});
for (let i = 0; i < arr.length; i++) {
const upload = await storage.ref(`/${path}/${arr[i].name}`).put(arr[i]);
imageUrl = await upload.ref.getDownloadURL();
imagesUrlArray.push(imageUrl);
}
return imagesUrlArray; // array of URLS of uploaded files
};
引发错误,ref.put不是函数 请指导我为什么我会遇到这个错误。
I am using firebase storage to upload the images and then store the urls to firebase db.
I am using that to upload the list of images but the code below works fine in firebase v8 but not in version 9
export const multiImageUpload = async (path = "Products", imageFileList) => {
let imagesUrlArray = [];
let imageUrl = "";
// array of files
let arr = imageFileList.map((item) => {
return item.originFileObj;
});
for (let i = 0; i < arr.length; i++) {
const upload = await storage.ref(`/${path}/${arr[i].name}`).put(arr[i]);
imageUrl = await upload.ref.getDownloadURL();
imagesUrlArray.push(imageUrl);
}
return imagesUrlArray; // array of URLS of uploaded files
};
it throws error that ref.put is not a function
please guide me why I am getting that error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导入{ref,get downloadurl,uploadBytesresumable,uploadBytes} from'firebase/storage';
import { ref, getDownloadURL, uploadBytesResumable, uploadBytes } from 'firebase/storage';