问题
I've searched everywhere on this but I cannot find a solution, how can I upload a public object to my google cloud storage, I want to have it so once the image is uploaded it can be viewed by anyone in the world.
It seems I can only get this done if I manually click the public link in google storage, but I want to have it so I can automatically make these objects public through googles api .
回答1:
The web interface doesn't provide a way to make the objects being uploaded public automatically, but you can do one of two things:
If you want to just make objects publicly readable during one particular session you could use gsutil to do it, e.g.,
gsutil -m cp -a public-read dir/* gs://your-bucket
If you want to make objects publicly readable across all future sessions you could set a default object ACL on the bucket, using a command like:
gsutil defacl set public-read gs://your-bucket
If you do that, uploads via the web interface (as well as by any other API requests, e.g., gsutil cp commands) will be made publicly readable automatically.
来源:https://stackoverflow.com/questions/31867160/upload-public-object-to-google-cloud-storage-with-public-link