I'm trying to implement a feed for images using Firebase Storage, think of it like the Instagram photo feed. My Problem:
- I don't know how many images there are in my Firebase reference folder
- I want only the images to be shown that have been taken, let's say in the last week
I tried downloading the images from the reference like this:
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
}
})
}
Here I run into the obvious problem: I've only downloaded 10 images, called "1","2",..., "10"
- What kind of way to name the images when users upload them would you suggest?
- How could I keep track of how many images there are?
- How could I delete those images from the reference that are older than a week?
- Should I use Image Cashing Libraries like Kingfisher or would you go with the above style?
Thank you guys really much for any help!