【发布时间】:2021-07-23 07:59:07
【问题描述】:
这是我的代码,我可以获得所有链接,但我无法将它们存储在数组中并将它们发送到 Firebase here is the codes here are the codes
期待答案谢谢
【问题讨论】:
-
请将您的代码粘贴为文本。
标签: firebase google-cloud-firestore storage
这是我的代码,我可以获得所有链接,但我无法将它们存储在数组中并将它们发送到 Firebase here is the codes here are the codes
期待答案谢谢
【问题讨论】:
标签: firebase google-cloud-firestore storage
在您的 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()”。
【讨论】: