firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.76k stars 873 forks source link

Offline support for Firebase Storage operations #2627

Open harrisonlo opened 4 years ago

harrisonlo commented 4 years ago

Describe your environment

Describe the problem

From my understanding, Firebase Storage does not yet support offline operations. To give some context, I am trying to implement a feature that allows users to "upload" an image in offline mode, which actually just stores to IndexedDB, and uploads when there is internet connection.

Then I thought, isn't this generally how Firestore works? So my question is: are offline operations coming to Firebase Storage? If not, I'd like to make a feature request on it. Also as a personal curiosity question, what is stopping the team from using the same offline logic from Firestore?

Thanks!

schmidt-sebastian commented 4 years ago

@harrisonlo Thanks for reporting this request! Firestore and Firebase Storage are very different under the hood. Firestore is a structured datastore that is meant to store small chunks of interpreted data, where Firebase Storage is a blob storage-based system designed to support much larger files. While offline support for Firebase Storage is certainly an often requested feature, the implementation would likely look very different from the implementation that we use in Firestore and hence these implementations cannot be shared.

Despite the popularity of this request, offline support for Firebase Storage is currently not a feature that is being worked on. We will take your input into consideration as we prioritize future work items. Thank you!

ccssmnn commented 2 years ago

Have you found a good workaround @harrisonlo?

Wrapping my head around offline functionality as well. Ideally, you would upload an image to storage while storing the reference to it in the Firestore together with other data that belongs to the image.

Maybe a nice workaround would be implementing a fallback, which uploads the image to the Firestore too, when offline. The first request to this image could then upload it to the storage and replacing it with the reference, or you could set up a triggered cloud function to handle this.

harrisonlo commented 2 years ago

@ccssmnn If the image is small enough to be stored in Firestore, that sounds like a reasonable approach!

BorisMolch commented 4 weeks ago

That would be indeed nice to have build in.