Google cloud storage 在没有完全访问权限的情况下更新Google存储对象元数据
当使用对存储桶具有读/写(但不是完全)访问权限的OAuth2身份验证令牌时,是否有方法更新Google存储中对象的元数据 我的天真尝试(HTTP将Google cloud storage 在没有完全访问权限的情况下更新Google存储对象元数据,google-cloud-storage,Google Cloud Storage,当使用对存储桶具有读/写(但不是完全)访问权限的OAuth2身份验证令牌时,是否有方法更新Google存储中对象的元数据 我的天真尝试(HTTP将x-goog-copy-source设置为同一对象,以及 x-goog-metadata-directive:REPLACE)失败,出现AccessDenied错误。gsutil似乎也有同样的问题: $ gsutil config -r -w [...] $ echo hello > foo.txt $ gsutil -h "x-goog-me
x-goog-copy-source
设置为同一对象,以及
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。
然而,在我看来,如果我能够删除对象并使用相同的授权使用不同的元数据重新上传它,那么就应该有一种方法来更改元数据 设置元数据适用于OAuth2。我建议运行此gsutil命令并将其生成的协议输出与您正在执行的操作进行比较:
gsutil-o gsutil:preference_api=xml-d setmeta-h x-goog-meta-data-00:gaj9cqbybqaaagfwclcqfycaaaahbvdgf0b2vzcqjzlg gs://your bucket/your object问题不在于使用OAuth2,而在于OAuth2和对bucket的读/写(但不是完全)访问。gsutil也有同样的问题,它只有在auth令牌具有完全访问权限时才能工作。