首页 > 解决方案 > 将所有图像从 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)

标签: pythonswiftfirebasefirebase-storage

解决方案


推荐阅读