Examples of Google Cloud Storage Used With Google App Engine (Python)
Question: Anybody have any code examples for using google cloud storage with google app
engine(python)?

The best I've seen so far is from an answer I received from a prior question I
posted: <https://code.google.com/p/appengine-gcs-
client/source/browse/trunk/python/demo/main.py>

However, the code seems to run successfully regardless of the connection and I
can't seem to find the files in my GCS bucket


Answer: main.py this script is uploading directly to GCS, by altering the the
create_upload_url function and removing gb_bucket_name it will use the blob
store.

    
    
    import os
    import urllib
    import webapp2
    
    from google.appengine.ext import blobstore
    from google.appengine.ext.webapp import blobstore_handlers
    
    class MainHandler(webapp2.RequestHandler):
      def get(self):
        upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='bucket_name')
        self.response.out.write('<html><body>')
        self.response.out.write('<form action="%s" method="POST" enctype="multipart/form-data">' % upload_url)
        self.response.out.write("""Upload File: <input type="file" name="file"><br> <input type="submit"
            name="submit" value="Submit"> </form></body></html>""")
    
    class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
      def post(self):
        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
    
        blob_info = upload_files[0]
        self.redirect('/serve/%s' % blob_info.key())
    
    class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler):
      def get(self, resource):
        resource = str(urllib.unquote(resource))
        blob_info = blobstore.BlobInfo.get(resource)
        self.send_blob(blob_info)
    
    app = webapp2.WSGIApplication([('/', MainHandler),
                                   ('/upload', UploadHandler),
                                   ('/serve/([^/]+)?', ServeHandler)],
                                  debug=True)
    

