尽管我是所有者,但无法作为所有者访问资源

时间:2014-11-27 15:36:37

标签: google-cloud-storage gsutil

我试图对存储桶和资源采取行动,但我一直在获取拒绝访问权限错误

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操作或覆盖文件时也一样。

1 个答案:

答案 0 :(得分:1)

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

您是否尝试使用开发人员控制台中API和API中列出的项目中的现有service accounts来运行该命令? auth - >证书?

如果您仍然收到该错误,则可能是通过App Engine上传了该对象。您可以使用以下代码Pythonlists the object ACLs using the JSON API中创建App Engine应用程序,因为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)