Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 422
adam-singer Avatar asked Dec 09 '13 18:12

adam-singer


People also ask

How do I get a bucket URL?

Get an S3 Object's URL #Navigate to the AWS S3 console and click on your bucket's name. Use the search input to find the object if necessary. Click on the checkbox next to the object's name. Click on the Copy URL button.

What is the URL for S3 bucket?

An S3 bucket can be accessed through its URL. The URL format of a bucket is either of two options: http://s3.amazonaws.com/[bucket_name]/ http://[bucket_name].s3.amazonaws.com/

What is object URL in S3?

A presigned URL is a URL that you can provide to your users to grant temporary access to a specific S3 object. Using the URL, a user can either READ the object or WRITE an Object (or update an existing object). The URL contains specific parameters which are set by your application.


2 Answers

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

like image 72
Brandon Yarbrough Avatar answered Sep 21 '22 16:09

Brandon Yarbrough


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

like image 29
adam-singer Avatar answered Sep 19 '22 16:09

adam-singer