I thought that by storing base64 string images, it would be a lot faster, because you don't need to upload neither download anything, and also a string would occupy less storage than an actual image!
I searched about this and I don't get why but everyone is saying that this would be a bad decision for the opposite of everything that I've said and I don't understand why?
it would be a lot faster
No, it would be slower (at scale) because you'd have to pay for the cost of the transformation to base64, and it would increase the amount of data to transfer.
you don't need to upload neither download anything
It's not clear to me why you'd say that. Any time data is transferred, it could be considered an "upload" or "download". When you load or save data in a cloud service, data transfer is always going to happen somehow. You can't avoid that.
a string would occupy less storage than an actual image!
A base64 encoding always increase the size of some data. I suggest reading about it to learn what it actually does to the data and why it's even used in the first place.
There are other reasons why specifically you would not want to store binary data in Firestore:
Storing the image data as a base64 string in Firestore is going to be significantly more expensive than storing the same image data in a dedicated file/blob storage such as Cloud Storage.
If you look at the pricing pages for Cloud Storage and Firestore , you can see that storing the same amount of data in Firestore will be about 10x more expensive. Worse: encoding the image data as a base64 string increases its size ~25% meaning that it gets even worse. The same applies if you look at the bandwidth cost for reading the data: that's about 10x more expensive on Firestore than from Cloud Storage,
Now if you were to get benefits from the increased cost that might be a good trade-off, but the extra features that Firestore offers (queryability, realtime syntax, offline access) typically don't apply to non-structured binary data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.