perl - 编辑 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"
}
}
尽管我有:
- 存储管理员
- 存储对象管理员
- 存储对象创建者
- 存储对象查看器
为我的用户启用。
为什么它不起作用?
简单上传对象确实有效,但我无法设置此元数据。
解决方案
要更新对象元数据需要storage.objects.update
权限。从Cloud Storage IAM 权限:
对象权限
...
storage.objects.update Update object metadata, excluding ACLs.
但是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.
推荐阅读
- reactjs - 切换多个按钮的反应
- python - 使用 EditBannedRequests 时的 Telethon TypeError
- r - 如何在R中转换数据
- python - 在 Django 模板 HTML 中访问元组中的第一个值
- c++ - C++/gRPC - IsCancelled 无法正常工作
- selenium - 如何在 Chrome 中禁用“您的连接不是私人的”屏幕?
- cakephp - Cakephp 3.x => 4.0 迁移:PHPStan\Analyser\MutatingScope 中的致命错误
- c - CS50 pset4 恢复 - while 循环中的 fread 仅在生成 7168 jpeg 后才到达结束
- mysql - SQL查询问题/帮助/建议
- python - 字符串键值对的字典