为GCP存储桶中所有以后上传的对象设置默认元数据

为GCP存储桶中所有以后上传的对象设置默认元数据

本文介绍了为GCP存储桶中所有以后上传的对象设置默认元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何为以后所有上载的对象设置默认元数据.

I would like to know how could I set default meta-data for all future uploaded objects.

我正在尝试将"Cache-Control:public,max-age = 3600"设置为托管静态网站的存储桶中每个对象的标头.对于所有现有对象,尽管无法找到默认方式为将来上传的对象设置元数据,但我使用了guide命令来设置元数据.

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.,开发人员正在使用GCP控制台上传对象,最近我意识到,当他们上传更新的HTML文件(替换存储桶中的HTML文件)时,元数据将重置.

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.

推荐答案

根据文档,如果对象没有 Cache-Control 条目,则为该对象提供服务时的默认值为 public,max-age = 3600 .

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.

如果您仍要修改此元数据,则可以使用 JSON API >云功能,每次将触发创建新对象或覆盖现有对象.

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.

这篇关于为GCP存储桶中所有以后上传的对象设置默认元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:19