如何在 Firebase 应用中获取 Cloud Storage 中所有文件的列表? [英] How to get a list of all files in Cloud Storage in a Firebase app?

查看:23
本文介绍了如何在 Firebase 应用中获取 Cloud Storage 中所有文件的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上传图片,一切正常,但我有 100 张图片,我想在我的 View 中显示所有图片,因为我在一个文件夹,我找不到这项工作的任何 API.

I'm working on uploading images, everything works great, but I have 100 pictures and I would like to show all of them in my View, as I get the complete list of the images in a folder, I can not find any API for this work.

推荐答案

自从 Firebase SDKs for JavaScript 版本 6.1iOS 版本 6.4a> 和 Android 版本 18.1 都有列出文件的方法.

Since Firebase SDKs for JavaScript release 6.1, iOS release 6.4, and Android release version 18.1 all have a method to list files.

文档到目前为止有点稀少,所以我建议查看 罗萨里奥的回答 了解详情.

The documentation is a bit sparse so far, so I recommend checking out Rosário's answer for details.

以前的答案,因为这种方法有时仍然有用:

Previous answer, since this approach can still be useful at times:

目前 Firebase SDK 中没有 API 调用来列出应用内 Cloud Storage 文件夹中的所有文件.如果您需要此类功能,您应该将文件的元数据(例如下载 URL)存储在可以列出它们的位置.Firebase 实时数据库Cloud Firestore 非常适合这种情况,您还可以轻松地与他人共享网址.

There currently is no API call in the Firebase SDK to list all files in a Cloud Storage folder from within an app. 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 and Cloud Firestore are perfect for this and allows you to also easily share the URLs with others.

您可以在我们的 FriendlyPix 示例应用中找到一个很好的(但有些复杂)示例.网页版相关代码为此处,但也有适用于 iOS 和 Android 的版本.

You can find a good (but somewhat involved) sample of this in our FriendlyPix sample app. The relevant code for the web version is here, but there are also versions for iOS and Android.

这篇关于如何在 Firebase 应用中获取 Cloud Storage 中所有文件的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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