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

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

问题描述

根据 https://cloud.google.com/appengine/docs/ python / googlecloudstorageclient / activate
$ b

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


默认存储桶名称通常是< app_id> .appspot.com,其中您
替换您的应用程序ID。您可以在
App Engine管理控制台应用程序设置页面的标签
Google Cloud Storage Bucket下找到存储桶名称。或者,您可以使用App
Identity get_default_gcs_bucket_name()方法以编程方式查找名称

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.

当我查看标签Google Cloud Storage Bucket,看到< app-id> .appspot.com ,其中< app-id> 是我的应用程序标识符。这似乎与上面段落中的前两句一致。

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.

但是,当我按照建议调用 get_default_gcs_bucket_name()时在最后一句中,返回值是 app_default_bucket

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

由于我将这个应用程序部署到多个站点, d喜欢使用方法调用。有没有办法让它返回真正的默认存储桶名称?

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?

推荐答案

在开发环境中,大多数服务被替换为存根。将应用部署到GAE后,get_default_gcs_bucket_name将返回< app_id> .appspot.com

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天全站免登陆