Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I setup a public Google Cloud Storage bucket

I am trying to upload files to a bucket on Google Cloud Storage, but I am having trouble figuring out how to set it up so that it is publicly writable and readable. In other words, I don't want to have to require authentication from the user in order to upload to the bucket. Does anybody know the steps to follow in order to set this up?

I would also like to know what I need to append to my request headers in order to upload files to this bucket. I am using the iOS API client, but if anybody knows what the raw headers are, I can probably figure out from there how to do it in iOS. At the moment, I am only including the following additional header: x-goog-project-id

like image 765
Michael Gaylord Avatar asked Sep 25 '14 12:09

Michael Gaylord


People also ask

How do I share a Google Cloud bucket?

Select the Share publicly checkbox next to files in your bucket that you want to share. Use the Public link next to the checkbox. Grant project access: Click IAM & Admin in the left side menu and grant users access to your project (and thus to your buckets and files, unless you set specific bucket or file permissions).

Are Google Cloud buckets free?

As you can see in the Cloud Storage pricing documentation there is a free tier of 5 Gb. So, having an empty bucket will have no fee. Show activity on this post. Creating a GCS bucket is a Class A operation, which means you'll be charged up to 5-10 cents for every 10,000 buckets you create.

Where is my Google Cloud bucket?

In the Google Cloud console, go to the Cloud Storage Buckets page. In the bucket list, find the bucket you want to verify, and check its column headers for the metadata you want to view.


2 Answers

For your first question, you can make your public your new uploaded objects with the following command that uses the gsutil acl syntax:

gsutil defacl ch -u allUsers:R gs://<bucket>

Now you need to give access to write to that bucket to everybody using the command:

gsutil acl ch -u allUsers:O gs://<bucket>

Regarding your other question, I'm not familiar with iOS but you can go to the bottom of this page and upload an object and you'll see the HTTP request that you can use in your code.

Also, there is Google API Client Library for Objetive-C and it seems that with that library you can manage Google Cloud Storage as per these files.

I hope it helps.

like image 133
Adrián Avatar answered Sep 19 '22 13:09

Adrián


Please consider using signed URLs (https://developers.google.com/storage/docs/accesscontrol#Signed-URLs ) instead of making your bucket publicly writable. Having a publicly writable bucket can be an opening to various forms of abuse, and also could result in your getting a surprisingly high bill if your bucket is discovered by someone on the Internet who then uploads large amounts of data to it.

like image 22
Mike Schwartz Avatar answered Sep 20 '22 13:09

Mike Schwartz