问题描述
我正在研究一个学校项目,因此选择使用Firebase作为通过我正在开发的应用程序上载/下载文件的存储选项.我希望能够向用户显示特定文件夹中所有文件的列表,并让该用户能够上传文件.但是,似乎访问Firebase存储中信息的唯一方法是作为开发人员知道文件是什么,而不是查找文件并动态显示它们.我希望我对此很有道理.
I am working on a school project and have elected to use Firebase as a storage option for uploading/downloading files via an app that I am developing. I would like to be able to display to the user a list of all the files within a specific folder, and also give that user the ability to upload files. However, it seems that the only way to access information within the firebase storage, is to, as the developer, know what the file is rather than find files and display them dynamically. I hope I am making sense with this.
基本上,我希望我的应用访问Firebase存储,转到指定的文件夹,然后根据文件夹中的内容在视图组中创建一堆图像按钮,而无需事先知道要做什么.期待.
Basically, I would like my app to access the firebase storage, go to a specified folder, and then create a bunch of image-buttons in a viewgroup based off of what is in the folder without having to know before hand what to expect.
是否可以通过元数据来实现?就像在这种情况下,当在此父文件夹中创建新文件/文件夹时,我是否还可以以编程方式更新该父文件夹的元数据,说:嘿,此文件夹中有这些特定文件吗?"
Would this be possible via metadata? As in, when ever a new file/folder is created within this parent folder, could I also programmatically update that parent folder's metadata to say, "hey there are these specific files within this folder?"
推荐答案
Firebase Storage中目前没有API可以列出文件夹中的所有文件.
Currently there is no API in Firebase Storage to list all files in a folder.
您可以做的是在其他地方维护元数据信息数据库(例如文件名和文件夹名).
What you can do is maintain a database of metadata information (such as file names and folder names) somewhere else.
Firebase实时数据库是完成此任务的不错选择.
Firebase Realtime Database would be a good choice for this task.
这篇关于如何在Firebase Storage中列出文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!