问题
I would like to know how could I set default meta-data for all future uploaded objects.
Am trying to set "Cache-Control:public,max-age=3600" as a header for each object in my bucket hosting a static website. For all the existing objects, I used the guide command to set meta data, although, can't find a way to set it by default for future uploaded objects.
P.S., Developers are using GCP console to upload the objects, and I recently realized that when they upload the updated HTML files (which replaces the one's on bucket), the meta-data resets.
回答1:
According to the documentation, if an object does not have a Cache-Control
entry, the default value when serving that object would be public,max-age=3600
.
In the case that you still want to modify this meta-data, you could do that using the JSON API inside a Cloud Funtion that would be triggered every time a new object is created or an existing one is overwritten.
来源:https://stackoverflow.com/questions/58111385/set-default-meta-data-for-all-future-uploaded-objects-in-gcp-bucket