Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default GCS bucket name

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?

like image 218
Lindsay Avatar asked Jun 29 '26 08:06

Lindsay


1 Answers

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)
like image 59
Arthur Avatar answered Jul 03 '26 23:07

Arthur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!