python - 将所有图像从 Firebase 存储下载到 UICollectionView Swift
问题描述
我正在尝试将我的 Firebase 存储中上传的所有图像下载到 Swift 中的 UICollection 视图并将其显示给用户。将图像上传到 Firebase 存储的后端代码使用 Python。目前,除非元数据(图像 URL)存储在实时数据库中,否则 Firebase 存储无法支持多次下载。大多数解决方案使用完整的基于 Web/Android/iOS 的方法来实现它,其中图像上传和下载逻辑位于同一平台上。这些解决方案的架构是与存储图像 URL 的 Firebase 数据库链接的云存储。
如何在 Python 中为上传的图像生成图像 URL,然后使用 Swift 访问它们?
上传图片到Storage的Python代码如下:
# Import gcloud
from firebase import firebase
import firebase_admin
import google.cloud
from google.cloud import storage
from firebase import firebase
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/home/pi/Desktop/<sample.json>"
firebase = firebase.FirebaseApplication('<firebaseurl>')
client = storage.Client()
bucket = client.get_bucket('<bucketurl>')
imagePath = '/home/pi/Desktop/birdIMG.jpeg'
imageBlob = bucket.blob("/")
imageBlob.upload_from_filename(imagePath)
解决方案
推荐阅读
- reactjs - 加载 http://localhost:8080/test 时有没有办法渲染 TSX 文件?
- java - 两个具有不同属性的 Mongo 存储库
- python - 在 Tkinter 中进行持续验证测试?
- android - 具有不同路线查找算法的导航应用程序
- node.js - 如何在 Eclipse-Che 上为 Node-Red 模块制作自定义堆栈?
- wcf - WCF 服务 - MTOM 安全模式和传输/消息属性的值
- c# - C# WinForms ListBox 将选择更改为第一项
- python - 从文件中选择一个随机图像并使用 pygame 显示它
- hibernate - 调用存储库的 save() 未插入表并给出 org.springframework.orm.jpa.JpaSystemException
- javascript - 模态弹出窗口在桌面上打开视频,但在触摸屏设备上打开应用程序