Reputation: 1481
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?
Upvotes: 3
Views: 4756
Reputation: 85
You can use the client library with the development server. However because there is no local emulation of Cloud Storage, all requests to read and write files must be sent over the Internet to an actual Cloud Storage bucket.
To use the client library with the development app server:
Activate a Cloud Storage bucket.
Run dev_appserver.py with the flag --default_gcs_bucket_name [BUCKET_NAME], replacing [BUCKET_NAME] with the name of the Cloud Storage bucket you are using.
This flag controls the bucket that will be returned when your application calls file.DefaultBucketName(ctx).
Found this in the google docs - https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/setting-up-cloud-storage#activating_a_cloud_storage_bucket
Upvotes: 0
Reputation: 31
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)
Upvotes: 3