Ancinek Ancinek - 1 year ago 197
iOS Question

Firebase - downloading few files

Is there a way to download couple of files (images) using Firebase Storage SDK and live cache those files, so after an image is downloaded the cache is updated?

Can I also observe in another view controller for this cache being updated?

I don't need a whole answer, just maybe a hint where to learn it. I've search through firebase documentation, found some info but I have absolutely no idea how to use it.

Answer Source

Take a look at NSURLCache. Basically what you'll do is, every time you upload a file to Firebase Storage, you can get a download URL and download it, then storeCachedResponse:forRequest: in the URL cache. Since this cache is shared, you can even grab it across activities.

Similarly, on download, you'll want to check for the cached request via cachedResponseForRequest: and if it doesn't exist, perform the download (at which point you cache the request for later).

Long term, we're hoping to enable this behavior for you out of the box, but for now, you can use NSURLCache to make it happen :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download