【发布时间】:2014-09-03 07:43:42
【问题描述】:
在使用具有对存储桶的读/写(但不是完全)访问权限的 OAuth2 身份验证令牌时,是否可以更新 Google 存储中对象的元数据?
我的幼稚尝试(将x-goog-copy-source 设置为同一对象的 HTTP PUT,以及
x-goog-metadata-directive: REPLACE) 失败并出现 AccessDenied 错误。 gsutil 似乎也有同样的问题:
$ gsutil config -r -w
[...]
$ echo hello > foo.txt
$ gsutil -h "x-goog-meta-foo: bar" cp foo.txt gs://nikratio-test/
Copying file://foo.txt [Content-Type=text/plain]...
Uploading gs://nikratio-test/foo.txt: 0 B/6 B
$ gsutil stat gs://nikratio-test/foo.txt
gs://nikratio-test/foo.txt:
Creation time: Sun, 09 Nov 2014 22:34:22 GMT
Content-Language: en
Content-Length: 6
Content-Type: text/plain
Metadata:
foo: bar
Hash (crc32c): NT3Yvg==
Hash (md5): sZRqySSS0jR8YjW00mERhA==
ETag: CID8ka7K7sECEAE=
Generation: 1415572462272000
Metageneration: 1
$ gsutil setmeta -h "x-goog-meta-foo: com" gs://nikratio-test/foo.txt
Setting metadata on gs://nikratio-test/foo.txt...
AccessDeniedException: 403 Forbidden
我认为这是因为 setmeta 操作还允许我更改对象的 ACL。 但是,在我看来,如果我能够删除对象并使用相同的授权使用不同的元数据重新上传它,那么确实应该有一种方法来更改元数据。
【问题讨论】: