【发布时间】:2021-02-13 08:33:02
【问题描述】:
目前,我可以通过 Firebase 存储参考按 文件名 获取 下载 url。
我想在特定子项不使用文件名且仅使用最后一个子项名称检索所有下载 URL。
只需将每个下载 url 添加到列表/数组中
我怎样才能用我给定的参考来做到这一点。
func getDownloadURL() {
let ref = Storage.storage().reference()
let fileName = "Lessons_Lesson1_Class1.mp3"
let starsRef = ref.child("Daily Meditations").child("Lessons").child("Lesson 1").child(fileName)
// Fetch the download URL
starsRef.downloadURL { url, error in
if let error = error {
// Handle any errors
print(error)
} else {
// Get the download URL for 'Lessons_Lesson1_Class1.mp3'
print(url)
}
}
}
【问题讨论】:
-
似乎您想使用列表文件 API。 firebase.google.com/docs/storage/ios/list-files
-
所以我使用了列表文件,但结果给了我存储位置而不是 downloadURL。
-
谢谢@DougStevenson。我通过查看这两个文档找到了一种方法来实现我所需要的。
-
您必须为找到的每个文件调用一次 getDownloadUrl。
标签: ios swift firebase firebase-storage