从python app访问Google Storage

时间:2013-03-21 13:36:47

标签: python google-app-engine google-cloud-storage

我遇到了问题,我想访问存储在我的Google云存储中的数据,但是我有错误,我不知道它来自哪里。

这是我的代码:

    DECORATOR = oauth2decorator_from_clientsecrets(
        CLIENT_SECRETS,
        scope=[
               'https://www.googleapis.com/auth/devstorage.read_only',
               ],
        message=MISSING_CLIENT_SECRETS_MESSAGE)
    http = DECORATOR.http()
    service_cloud = build("storage", "v1beta1")
    list_response = service_cloud.objects().list(bucket="directory_structure").execute(http=http)

    params = {'directory_list':list_response['items']}
    return self.render_template('directoryChoice.html', **params)

我收到的错误信息是:

Traceback (most recent call last): 
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__ rv = self.router.dispatch(request, response) 
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher return route.handler_adapter(request, response) 
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__ return handler.dispatch() 
File "/base/data/home/apps/s~jba-gae-boilerplate/dev.366111306063368728/boilerplate/lib/basehandler.py", line 162, in dispatch webapp2.RequestHandler.dispatch(self) 
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch return self.handle_exception(e, self.app.debug) 
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch return method(*args, **kwargs) 
File "/base/data/home/apps/s~jba-gae-boilerplate/dev.366111306063368728/web/lib/oauth2client/appengine.py", line 469, in check_oauth return method(request_handler, *args, **kwargs) 
File "/base/data/home/apps/s~jba-gae-boilerplate/dev.366111306063368728/web/handlers.py", line 190, in get list_response = service_cloud.objects().list(bucket="jba_directory").execute(http=http) 
File "/base/data/home/apps/s~jba-gae-boilerplate/dev.366111306063368728/web/lib/oauth2client/util.py", line 120, in positional_wrapper return wrapped(*args, **kwargs) 
File "/base/data/home/apps/s~jba-gae-boilerplate/dev.366111306063368728/web/lib/apiclient/http.py", line 678, in execute raise HttpError(resp, content, uri=self.uri) 
HttpError:

1 个答案:

答案 0 :(得分:0)

有一点看起来有点奇怪:

在您的代码中,您列出了directory_structure存储桶,但回溯引用了jba_directory。有某种不匹配。也许在包装装饰器或您在此处包含的片段上方的其他代码中?