How do I store images on Google Firebase and which solution do I use?
Background
I am looking to create a web app (Python, HTML & JS) that uses Google's Firebase for the backend storage. I believe that the Realtime Database will be sufficient for my needs (the website is in e-commerce style) but am trying to store profile pictures for the users. I am aware that images can generally be stored as blurbs. I haven't been able to figure out whether the Realtime Database, Cloud Firestore or Cloud Storage is most appropriate.
Request
Please explain which would be more capable, why and how it can be implemented.
CodePudding user response:
There are a couple of options:
Thumbnails
You can store small thumbnails as Base64 encoded strings within the RTDB or Cloud Firestore. The benefit is that you can retrieve the profile picture in the same request. The downside is that the browser will need to do a little more work to render the images.
Standard sized images
You should use Cloud Storage for anything other than the tiniest blobs. You can either fetch these directly (as JPG or PNG) using client-side JS (from the browser) or pass them in your response payload, if you intend to use Server Side Rendering with Cloud Functions.
Language support
Cloud Functions for Firebase do not currently support Python. In order to implement a Python based back-end, you will need to deploy using gcloud functions deploy
for each function. If you intend to build a SSR application, you may want to look at using a framework, such as Next or Nuxt, which you can deploy directly with the Firebase CLI.