如何在统一存储桶上设置 Cache-Control 元数据?

How do I set Cache-Control metadata on a uniform bucket?

我在 Google 云存储上有一桶图像。我已经将桶的访问控制设置为统一并使桶public。我现在想将存储桶的 Cache-Control 元数据设置为 max-age 一年,而不是默认的一小时。

但是,我无法为单个对象设置元数据,因为这是一个统一的存储桶。我只是得到

AccessDeniedException: 403 <my email> does not have storage.objects.update access to the Google Cloud Storage object.

这是预期的。

我在 GUI 中找不到选项或云命令 shell 无法在统一存储桶上设置元数据,有人知道怎么做吗,或者我是否需要切换回细粒度访问控制?

您遇到的错误与设置 object/s 元数据无关!这意味着您正在使用的 identitygoogle accountservice-account)没有权限更新 buckets.

中的对象

您需要查看授予您 identity 的 IAM 权限并添加所有必需的 IAM 权限。


您可以编辑 Cloud Console object/s 元数据中的 Cache-Control,如下所示:

  1. In the Google Cloud Console, go to the Cloud Storage Browser page.

  2. In the list of buckets, click on the name of the bucket that contains the desired object.

  3. The Bucket details page opens, with the Objects tab selected.

  4. Navigate to the object, which may be located in a folder.

  5. Certain object metadata values, such as the object's size and storage class, are displayed along with the object's name.

  6. Click the more actions menu () associated with the object.

  7. Click Edit metadata.

    The overlay window that appears shows the current values for the object's editable metadata.


参考:documentation.

注:

The Cloud Console does not provide an exhaustive list of metadata associated with objects. To view all of an object's metadata, follow the gsutil instructions.