Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cost of getting url of a firebase image [closed]

I was reading the firebase Storage prices and couldn't visualize if there is any cost into getting the URL of an image/file stored. I got that there is price for the download but would like to know for sure if there is any price involved when generating the URL.

I want to know if would be more practical to save the URL one time with my data and then use the saved URL or if its better to retrieve the URL based on the location of the image (that follows a logical pattern) each time it is needed.

I was looking for the price here: https://cloud.google.com/storage/pricing

UPDATE 1 - Just leaving here the answer from the firebase support if anyone else need it:

The act of retrieving the download URL does have a billable cost, both in terms of network egress as well as the use of a Class B operation. Depending on your use-case, these GCS-related costs may or may not be more costly than simply storing the URL as a string in Firestore.

Another thing to consider would be security. Since file downloads performed through these URLs are not gated by Cloud Storage's security rules at all, storing the URL in Firestore would mean that anyone who has access to the Firestore document automatically has immediate access to the file itself. This might be fine depending on your use-case, but if file access needs to be controlled independently of Firestore document access, then storing a generic storage path in Firestore may be the better option.

like image 702
Rodrigo S Avatar asked Mar 10 '19 19:03

Rodrigo S


1 Answers

If you want the images from Cloud Storage to be publicly readable for users without requiring authentication, it is idiomatic to generate the download URL once and store it in a location where the users can read it.

Generating a new download URL each time around will take more time, since it requires an extra roundtrip to Google's servers. As far as I know there is no charge for generating the URL, but you may be charged for the bandwidth the request consumes.

If you only want authenticated users to be able to access the image file in Cloud Storage, you should not generate a download URL at all, but instead use the Firebase SDK to download the image data.

like image 134
Frank van Puffelen Avatar answered Oct 21 '22 06:10

Frank van Puffelen