默认 GCS 存储桶名称 [英] Default GCS bucket name

查看:40
本文介绍了默认 GCS 存储桶名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

According to https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/activate:

The default bucket name is typically <app_id>.appspot.com, where you replace with your app ID. You can find the bucket name in the App Engine Admin console Application Settings page, under the label Google Cloud Storage Bucket. Alternatively, you can use the App Identity get_default_gcs_bucket_name() method to find the name programmatically.

When I look under the label Google Cloud Storage Bucket, I see <app-id>.appspot.com, where <app-id> is my application's identifier. That seems consistent with the first two sentences in the paragraph above.

But when I call get_default_gcs_bucket_name() as suggested in the final sentence, the return value is app_default_bucket.

Since I deploy this app to several sites, I'd like to use the method call. Is there anyway to get it to return the real default bucket name?

解决方案

Most services are replaced with stub in the development environment. Once you deploy the app to GAE, get_default_gcs_bucket_name will return <app_id>.appspot.com.

I verified the behavior with the following app:

import webapp2

from google.appengine.api import app_identity


class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write(app_identity.get_default_gcs_bucket_name())

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

这篇关于默认 GCS 存储桶名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆