Kunal
Kunal

Reputation: 211

How to store images in firestore collection?

I am new to using firestore and was wondering how can you store images in a firestore collection. I am building an app and want to retrieve the images that are stored in the firestore collection, but i couldn't find a image datatype field. Any help would be appreciated. Thank you.

Upvotes: 1

Views: 1246

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317760

There is no "easy" way to store images in Firestore. It's not designed for that. The best you can do is encode the image as a string (for example, with base64 encoding). Bear in mind that the maximum size of a Firestore document is 1MB, so it won't be big enough for typical photos.

I strongly suggest you look into storing images in Cloud Storage, then storing the path of the file in Firestore. This is the most common solution.

Upvotes: 2

Related Questions