How do you get or generate a URL to the object in a bucket?

30,688

Solution 1

Yes. Assuming that the objects are publicly accessible:

http://BUCKET_NAME.storage.googleapis.com/OBJECT_NAME

You can also use:

http://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME

Both HTTP and HTTPS work fine. Note that the object must be readable by anonymous users, or else the download will fail. More documentation is available at https://developers.google.com/storage/docs/reference-uris

If it is the case that the objects are NOT publicly accessible and you only want the one user to be able to access them, you can generate a signed URL that will allow only the holder of the URL to download the object, and even then only for a limited period of time. I recommend using one of the GCS client libraries for this, as it's easy to get the signing code slightly wrong: https://developers.google.com/storage/docs/accesscontrol#Signed-URLs

Solution 2

One way is to use https://storage.cloud.google.com// see more documentation at https://developers.google.com/storage/docs/collaboration#browser

Share:
30,688
adam-singer
Author by

adam-singer

Fun

Updated on December 10, 2020

Comments

  • adam-singer
    adam-singer over 3 years

    I'm storing objects in buckets on google cloud storage. I would like to provide a http url to the object for download. Is there a standard convention or way to expose files stored in cloud storage as http urls?