iOS/Swift:如何在 Feed 中管理从 Firebase 下载的图片
iOS/Swift: How to manage image downloading from Firebase in a feed
我正在尝试使用 Firebase 存储实现图像提要,将其想象成 Instagram 照片提要。
我的问题:
- 我不知道我的 Firebase 参考文件夹中有多少张图片
- 我只想显示已拍摄的图像,比方说在上周
我试过像这样从参考资料中下载图片:
let storageRef = storage.reference()
for i in 0...10 {
let imageRef = storageRef.child("images/" + String(i) + ".jpg")
imageRef.dataWithMaxSize((10 * 1024 * 1024), completion: { (data, error) -> Void in
if (error != nil) {
print(error)
} else {
let image: UIImage! = UIImage(data: data!)
self.downloadedPhotos.append(image) //downloadedPhotos is an array of UIImages
self.configureFeed() //takes care of some UI
}
})
}
在这里我 运行 遇到了一个明显的问题:我只下载了 10 张图片,名为“1”,“2”,...,“10”
- 您建议用户上传图片时采用什么样的命名方式?
- 我怎样才能知道有多少张图片?
- 如何从参考中删除那些超过一周的图像?
- 我应该使用像 Kingfisher 这样的 Image Cashing Libraries 还是你会选择上面的风格?
非常感谢你们的帮助!
让我们一次处理这些:
- 用户上传图片时,你会用什么样的方式命名?
建议?
我会看看其他许多这样的问题:Retrieving image from Firebase Storage using Swift
- 我怎样才能知道有多少张图片?
见上文。
- 我怎样才能从参考中删除那些早于
周?
您可以使用 Object Lifecycle Management to delete images after a certain time. Deleting them from the database would be harder--maybe an integration with Google Cloud Functions GCS notifications 可以同步它。
- 我应该使用像 Kingfisher 这样的图像兑现库还是
你喜欢上面的风格吗?
我完全推荐在从实时数据库中拉取下载图像后使用像 SDWebImage or PINRemoteImage 这样的图像加载器。
我正在尝试使用 Firebase 存储实现图像提要,将其想象成 Instagram 照片提要。 我的问题:
- 我不知道我的 Firebase 参考文件夹中有多少张图片
- 我只想显示已拍摄的图像,比方说在上周
我试过像这样从参考资料中下载图片:
let storageRef = storage.reference()
for i in 0...10 {
let imageRef = storageRef.child("images/" + String(i) + ".jpg")
imageRef.dataWithMaxSize((10 * 1024 * 1024), completion: { (data, error) -> Void in
if (error != nil) {
print(error)
} else {
let image: UIImage! = UIImage(data: data!)
self.downloadedPhotos.append(image) //downloadedPhotos is an array of UIImages
self.configureFeed() //takes care of some UI
}
})
}
在这里我 运行 遇到了一个明显的问题:我只下载了 10 张图片,名为“1”,“2”,...,“10”
- 您建议用户上传图片时采用什么样的命名方式?
- 我怎样才能知道有多少张图片?
- 如何从参考中删除那些超过一周的图像?
- 我应该使用像 Kingfisher 这样的 Image Cashing Libraries 还是你会选择上面的风格?
非常感谢你们的帮助!
让我们一次处理这些:
- 用户上传图片时,你会用什么样的方式命名? 建议?
我会看看其他许多这样的问题:Retrieving image from Firebase Storage using Swift
- 我怎样才能知道有多少张图片?
见上文。
- 我怎样才能从参考中删除那些早于 周?
您可以使用 Object Lifecycle Management to delete images after a certain time. Deleting them from the database would be harder--maybe an integration with Google Cloud Functions GCS notifications 可以同步它。
- 我应该使用像 Kingfisher 这样的图像兑现库还是
你喜欢上面的风格吗?
我完全推荐在从实时数据库中拉取下载图像后使用像 SDWebImage or PINRemoteImage 这样的图像加载器。