How do I setup a public Google Cloud Storage bucket

血红的双手。 提交于 2021-02-18 09:59:31

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/26039173/how-do-i-setup-a-public-google-cloud-storage-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!