GAE Python get default bucket fxn returns None
Question: I'm a GCS newbie trying to write an app that uploads a file to a bucket I have
created. I've followed the tutorial and created a bucket using the browser
interface. However when I programmatically try to access my bucket, I get an
error. Instead of printing my default bucket name, my app ouputs "None". My
ENTIRE app code is as shown:

    
    
    import webapp2
    from google.appengine.api import app_identity
    
    class MainHandler(webapp2.RequestHandler):
        def get(self):
            self.response.write(app_identity.get_default_gcs_bucket_name())
    
    app = webapp2.WSGIApplication([
        ('/', MainHandler)
    ], debug=True)
    

What am I doing wrong?


Answer: **Update** :

Seems you can now create a default bucket **in the new console** too by
visiting your app engine's application settings in the cloud console
<https://console.cloud.google.com/appengine/settings?project=>

[![Create Default
Bucket](http://i.stack.imgur.com/ltbDK.png)](http://i.stack.imgur.com/ltbDK.png)

* * *

**Original** :

You're getting `NONE` because by default there's no longer a default bucket

> About default Cloud Storage buckets
>
> Applications created using the old App Engine console could use a default
> Cloud Storage bucket, which had free quota and didn't require billing to be
> enabled for the app. These applications continue to work as before in the
> Google Cloud Platform Console.
>
> However, new App Engine projects created in the Google Cloud Platform
> Console don't have a default Cloud Storage bucket. Instead you must use a
> standard Cloud Storage bucket as described above.

But since you manually created the bucket, you will already have its name and
so can probably skip `app_identity.get_default_gcs_bucket_name()` and hardcode
the bucket name or call it from a config variable, etc, etc.

You can then use the [gcloud-
python](https://github.com/GoogleCloudPlatform/gcloud-python) lib to upload
files to your bucket:

    
    
    from gcloud import storage
    
    client = storage.Client()
    bucket = client.get_bucket('<bucket-name>')
    my_file = bucket.blob('/path/to/be/saved/in/bucket')
    my_file.upload_from_filename(filename='/path/to/local/file')
    

You'll have to
[vendor](https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring)
the gcloud lib if you're doing this on app engine.

All that said and done if you still want the old behaviour of getting the
default bucket which is in the format `<project-id.appspot.com>`, you can
follow [GAEfan's answer](http://stackoverflow.com/a/24237328/2295256), in
short:

> Go to the old console, appengine.google.com > Application Settings > Cloud
> Integration > Create

