这是我的代码,我可以获取所有链接,但我无法将它们存储在数组中并将它们发送到 Firebase here is the codes here are the codes
期待答案,谢谢
答案 0 :(得分:0)
在您的 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()”。