从Firebase存储获取多个URL

huangapple go评论137阅读模式
英文:

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(&quot;profileImages&quot;).child(&quot;femaleProfileImages&quot;); 

Question: How do I go about acquiring all of the urls included within? I will add them to an ArrayList:

String sitePrefix= &quot;https://&quot;;
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&lt;ListResult&gt;() {
        @Override
        public void onSuccess(ListResult result) {
            // Iterate over result.items and get the URLs individually.
        }
    }
);

huangapple
  • 本文由 发表于 2020年8月14日 08:01:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/63404751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定