英文:
Getting multiple URLs from Firebase Storage
问题
需要: 为了我的应用程序,我需要一个包含来自 Firebase 存储子文件夹的所有 URL 的 ArrayList。
我已经创建了一个引用,其中包含所有图像:
StorageReference storageRefFemale = FirebaseStorage.getInstance().getReference().child("profileImages").child("femaleProfileImages");
问题: 我应该如何获取其中包含的所有 URL?我将把它们添加到一个 ArrayList 中:
String sitePrefix = "https://";
ArrayList<String> photoArrayFemale = new ArrayList<>();
photoArrayFemale.add(...); // 对于存储中的每个项目
根据我所了解的情况,storageRefFemale.getDownloadUrl()
只返回一个值。请提供建议,如果需要,也请告诉我是否应该在帖子中添加其他内容。谢谢!
英文:
Needed: For my app, I need an ArrayList of all urls in a Firebase Storage from a subfolder of said storage.
I have created the reference in which all of the images are located:
StorageReference storageRefFemale = FirebaseStorage.getInstance().getReference().child("profileImages").child("femaleProfileImages");
Question: How do I go about acquiring all of the urls included within? I will add them to an ArrayList:
String sitePrefix= "https://";
ArrayList photoArrayFemale = new ArrayList();
photoArrayFemale.add(...); //for each item in the Storage
From what I can tell, storageRefFemale.getDownloadUrl() only returns one value. Please advise and please let me know if I should add anything else to the post. Thank you!
答案1
得分: 1
storageRef.listAll().addOnSuccessListener(
new OnSuccessListener<ListResult>() {
@Override
public void onSuccess(ListResult result) {
// Iterate over result.items and get the URLs individually.
}
}
);
英文:
storageRef.listAll().addOnSuccessListener(
new OnSuccessListener<ListResult>() {
@Override
public void onSuccess(ListResult result) {
// Iterate over result.items and get the URLs individually.
}
}
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论