firebase - Flutter 从 Firebase 存储中获取图像
问题描述
我找到了两种从 firebase 存储中获取图像的方法。
- 使用图像路径
将图像保存到存储时,将该图像路径存储到 firestore,并在获取图像时,使用来自 firestore 的图像路径并调用 FirebaseStorage 实例。
// In this case, get & post imagePath info String through firebase firestore
FirebaseStorage.instance.storage.ref().child('imagePath').getData()
- 使用图片网址
将图像保存到存储时,将该图像 url 存储到 firestore,并在获取图像时,使用 firestore 中的图像 url 作为网络图像(无需调用 FirebaseStorage 实例)。
// In this case, get & post imageUrl String through firebase firestore
Firestore.instance.collection('images').document('foo').get()
哪个是更好的方法?有性能差异吗?
解决方案
第一个片段通过该产品的 Firebase SDK 从 Cloud Storage 检索图像数据。Cloud Storage 是一种用于存储任何规模的博客/文件数据的解决方案。
第二个片段通过该产品的 Firebase SDK 从 Cloud Firestore 检索图像数据。Firestore 是一个 NoSQL 数据库,也适用于任何规模。
Cloud Storage 和 Cloud Firestore 是完全不同的产品,您必须自己选择要使用的产品。但一般指导是将非结构化数据存储到 Storage 中,并将更多结构化数据存储在 Firestore 中。
推荐阅读
- javascript - 所有事件都有一个监听器数组还是所有“发射器”都有一个监听器数组?
- html - Iron Python 在 Spotfire 客户端的初始加载中触发,但对于 Spotfire Web 播放器没有触发
- python - 反应角色 Discord.py
- c# - C# 如何将时间 [ms, s, m, h, d] 作为字符串转换为秒作为 int
- automake - automake 需要 makeinfo 而 texinfo 需要 aclocal
- r - R Shiny 反应性错误,我该如何解决?
- javascript - 如何从 React-Router-Dom 停止对 Link 元素的传播?
- sql-server - 使用 JDBC 的命名管道连接
- php - 无法在本地 WordPress 中增加最大上传文件大小我尝试了所有方法仍然显示最大上传文件大小:2 MB
- javascript - 将跨屏幕布局的 div 更改为屏幕更改后滑块中的 div