Reputation: 1870
Recently I tried to upload an image to my firebase db. Currently, I'm uploading a whole blob
file, which looks like:
"userImg": {
"preview": "blob:http://localhost:3000/e52a768c-3639-4b77-88ed-1db876c53f12"
}
And as you can see, it loads localhost
path, which of course won't work when downloading the data from the db into user's browser.
Important: I'm using http POST request.
My question: What should I do to properly store it in the db?
I thought about encoding it into base64
and then store it, and when user downloads it - encode it. But won't it kill user browser, when there's a lot of files to encode, will it?
Looking for any hints. Thank u ! :)
Upvotes: 1
Views: 721
Reputation: 508
You can use Firebase Storage for storing images, it specifically is for the purpose of storing files. And store the URL for file in DB.
base64 gets very big for good quality images and it is not adivsable to store them to a db.
Upvotes: 1