首页 > 解决方案 > 编辑 Google 存储对象元数据需要哪些权限?

问题描述

我有以下 Perl 代码:

  $response = $process->request('PATCH',
                                "https://www.googleapis.com/storage/v1/b/$Bucket/o/$EscapedName",
                                '{"content-type": "image/jpeg"}',
#                                 '{"metadata": {"Content-Type": "image/jpeg"}}',
                                {'Content-Type' => 'application/json'});
  unless ($response->is_success) {
    print "Content-Type: text/plain\n\n";
    print $response->status_line . "\n" . $response->decoded_content . "\n" ;
    exit;
  }

它产生

403 Forbidden
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}

尽管我有:

为我的用户启用。

为什么它不起作用?

简单上传对象确实有效,但我无法设置此元数据。

标签: perlgoogle-cloud-storage

解决方案


要更新对象元数据需要storage.objects.update权限。从Cloud Storage IAM 权限

对象权限

...

storage.objects.update    Update object metadata, excluding ACLs.

但是roles/storage.objectAdminroles/storage.admin角色(假设这就是您列出的角色的意思)应该已经包含该权限,因此可能还有其他东西在起作用。从标准角色

roles/storage.objectAdmin  Full control over objects, including listing,    storage.objects.*
                           creating, viewing, and deleting objects.
                           Does not grant permission to read or edit 
                           bucket metadata.
roles/storage.admin        Full control of buckets and objects.             storage.buckets.*
                           When applied to an individual bucket, control    storage.objects.*
                           only to the specified bucket and objects within
                           the bucket.

推荐阅读