gpt4 book ai didi

google-cloud-storage - 尽管我是所有者,但无法以所有者身份访问资源

转载 作者:行者123 更新时间:2023-12-04 18:05:44 24 4
gpt4 key购买 nike

我正在尝试对存储桶和资源采取行动,但我不断收到访问被拒绝的错误

例如

```

$ gsutil ls -L gs://images/large

gs://images/large/aa.png:
Creation time: Tue, 25 Nov 2014 20:03:19 GMT
Cache-Control: public, max-age=2592000
Content-Length: 343034
Content-Type: image/png
Generation: 1416945799570000
Metageneration: 2
ACL: ACCESS DENIED. Note: you need OWNER permission
on the object to read its ACL.

```

当我尝试运行 acl 操作或覆盖文件时也是如此。

最佳答案

首先,我想提一下,作为存储桶所有者意味着您始终可以删除存储在该存储桶中的对象,但如果默认 ACL 被覆盖,您可能没有对象所有者权限。这与存在 super 用户概念的流行操作系统的工作方式不同。

您是否尝试使用现有的 service accounts 运行该命令?在 APIs & auth -> Credentials 的 Developers Console 中列出的项目中?

如果您仍然收到该错误,则该对象可能是通过 App Engine 上传的。您可以在 Python 中制作 App Engine 应用程序使用以下代码 lists the object ACLs using the JSON API因为 App Engine 有自己的服务帐户 ( <project ID>@appspot.gserviceaccount.com ),而且它与 Developers Console 中显示的不同。

#!/usr/bin/env python                                                                                                                     
import webapp2
from google.appengine.api import app_identity
from google.appengine.api import urlfetch


class MainPage(webapp2.RequestHandler):
def get(self):
scope = "https://www.googleapis.com/auth/devstorage.full_control"
authorization_token, _ = app_identity.get_access_token(scope)
acls = urlfetch.fetch(
"https://www.googleapis.com/storage/v1/b/<bucket>/o/<object/acl",
method=urlfetch.GET,
headers = {"Content-Type": "application/json", "Authorization": "OAuth " + authorization_token})
self.response.headers['Content-Type'] = 'application/json'
self.response.write(acls.content)

application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)

关于google-cloud-storage - 尽管我是所有者,但无法以所有者身份访问资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27174239/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com