如何从Firebase存储中的文件夹中获取所有图像,并将其显示在列表视图中 [英] How do I get all images from a folder in the Firebase Storage and displayed them in a listview

查看:214
本文介绍了如何从Firebase存储中的文件夹中获取所有图像,并将其显示在列表视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在学习Android的Firebase存储,并且遇到了麻烦.我想获取所有存储在Firebase存储中的文件夹中的图像,一旦获得对它们的引用,便想将它们存储在ListView或RecyclerView中.我怎么做?我的意思是我可以引用该文件夹:

So I'm learning about Firebase Storage for android and I've hit a wall. I want to get all the images I have stored in a folder in my Firebase Storage and once I get a reference to them I want to stored them in a ListView or RecyclerView. How Do i do that? I mean I can get reference to the folder:

StorageReference storageReference =  FirebaseStorage.getInstance().getReference("gallery");

但是然后如何获取Gallery文件夹中的所有图像并将它们显示在Listview或recyclerView中?

But then how do I get all the images in the gallery folder and display them in a Listview or recyclerView?

推荐答案

Firebase Storage当前没有API调用可列出文件夹中的所有文件.如果需要这种功能,则应将文件的元数据(例如下载URL)存储在可以列出它们的位置. Firebase实时数据库非常适合此操作,您还可以轻松与他人共享URL.

There currently is no API call in Firebase Storage to list all files in a folder. If you need such functionality, you should store the metadata of the files (such as the download URLs) in a place where you can list them. The Firebase Realtime Database is perfect for this and allows you to also easily share the URLs with others.

将图像名称添加到 Firebase实时数据库并获取

add image name to the Firebase Realtime Databse and fetch from it

并获得类似的网址,

mStoreRef.child("<folderNameInStorage>/" +""<imageName>).getDownloadUrl().addOnSuccessListener();

这就是方法.

这篇关于如何从Firebase存储中的文件夹中获取所有图像,并将其显示在列表视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆