I have a list of products from the api response which has image url for the product. The url is like
https://storage.googleapis.com/bucket-1/logos/My%20Product.png
but I am not able to access this image from the google cloud bucket as the bucket is not public. I have configured firebase project and the cloud bucket is also in the same project. but I won’t be able to see the bucket in firebase console. it only shows in google console.
Do we have to set this bucket as public to access the images in the app?
Could you please suggest solutions to access this url without making this bucket public?
2
Answers
Yes, see the documentation on making objects public. There are no alternatives to make this URL work for anyone to download the content.
Minimally you have to set the permission on the single object to make it public, but if you have multiple objects, you might as well set the permission on the entire bucket.
If the image is meant to be read by anonymous users viewing it on a website, marking the image as publicly readable probably makes the most sense. If you can’t do that for some reason (perhaps you’re using an org policy that forbids public objects), you have a couple of other options.
One option is to vend a dynamic, signed, short-lived, download URL for the image each time the page is rendered. This is a bit more complicated, and it’s not a perfect solution, but it will result in public users being able to see the "not public" object. You can generate such a URL in a few ways, for example with the getSignedUrl() function. Note that, although they only live for a configurable amount of time, while that time hasn’t expired, anybody who has the URL can download the object with it.