3

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

例如

```

$ 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 操作或覆盖文件时也是如此。

4

1 回答 1

1

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

您是否尝试使用开发人员控制台中 APIs & auth -> Credentials 中列出的项目中的现有服务帐户运行该命令?

如果您仍然收到该错误,则该对象可能是通过 App Engine 上传的。您可以使用以下代码在Python中创建 App Engine 应用程序,该代码使用 JSON API 列出对象 ACL,因为 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)
于 2015-02-02T08:13:49.627 回答