如何将多个图像上传到 firebase 存储并将所有 url 存储在一个数组中以 firestore
how to upload multiple images to firebase storage and store all urls in an array to firestore
这是我的代码,我可以获得所有链接,但我无法将它们存储在数组中并将它们发送到 Firebase
here is the codes
here are the codes
期待答案谢谢
在您的 uploadImageAsPromise 函数中:
// make the function async
const storageRef = firebase.storage().ref();
const fileUploads = files.map(file => storageRef.child(file.name).put(file));
const uploadRequests = await Promise.all(fileUploads)
const fileURLReqs = uploadRequests.map(f => f.ref.getDownloadURL())
const fileUrls = await Promise.all(fileURLReqs)
fileUrls 将是下载 URL 数组。
如果您需要显示每次上传的进度,那么您 运行 在 fileUploads 数组上循环并在每个元素上使用“task.on()”。
这是我的代码,我可以获得所有链接,但我无法将它们存储在数组中并将它们发送到 Firebase here is the codes here are the codes
期待答案谢谢
在您的 uploadImageAsPromise 函数中:
// make the function async
const storageRef = firebase.storage().ref();
const fileUploads = files.map(file => storageRef.child(file.name).put(file));
const uploadRequests = await Promise.all(fileUploads)
const fileURLReqs = uploadRequests.map(f => f.ref.getDownloadURL())
const fileUrls = await Promise.all(fileURLReqs)
fileUrls 将是下载 URL 数组。
如果您需要显示每次上传的进度,那么您 运行 在 fileUploads 数组上循环并在每个元素上使用“task.on()”。