gpt4 book ai didi

google-app-engine - 默认 GCS 存储桶名称

转载 作者:行者123 更新时间:2023-12-04 14:33:28 25 4
gpt4 key购买 nike

根据 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.

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

但是当我调用 get_default_gcs_bucket_name()正如最后一句话所建议的,返回值为app_default_bucket .

由于我将此应用程序部署到多个站点,所以我想使用方法调用。无论如何让它返回真正的默认存储桶名称?

最佳答案

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

我使用以下应用验证了该行为:

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)

关于google-app-engine - 默认 GCS 存储桶名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26394932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com