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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With