我正在尝试对存储桶和资源进行操作,但我不断收到访问被拒绝的错误
e.g.
```
$ 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 被覆盖,您可能没有对象所有者权限。这与具有超级用户概念的流行操作系统的工作方式不同。
您是否尝试使用现有的运行该命令服务帐户在开发者控制台的 API 和身份验证 -> 凭据中列出的项目中?
如果您仍然收到该错误,则该对象可能是通过 App Engine 上传的。您可以在以下位置创建 App Engine 应用程序Python与以下代码使用 JSON API 列出对象 ACL因为 App Engine 有自己的服务帐户(<project ID>@appspot.gserviceaccount.com
)并且它与开发者控制台中显示的不同。
#!/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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)