我有以下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"
}
}尽管我有:
为我的用户启用。
为什么不起作用?
简单地上传对象是可行的,但是我不能设置这个元数据。
发布于 2018-10-07 20:08:44
要更新对象元数据,需要storage.objects.update权限。来自云存储IAM权限
对象权限 ..。 storage.objects.update更新对象元数据,不包括ACL。
但是,roles/storage.objectAdmin和roles/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.发布于 2018-10-08 21:35:00
对象资源中属性的名称是contentType,您正在传递content-type
https://stackoverflow.com/questions/52692119
复制相似问题