What is the GCS equivalent of the blobstore "Create_upload_url"?
<p>We currently use blobstore.create_upload_url to create upload urls to be used on the frontend see <a href="https://cloud.google.com/appengine/docs/python/blobstore/#Python_Uploading_a_blob" rel="nofollow">Uploading a blob</a>.
However, with the push toward Google Cloud Storage (GCS) by Google, I'd like to use GCS instead of the blobstore. We use currently blobstore.create_upload_url but I can't find anything equivalent in the GCS documentation. Am I missing something? Is there a better way to upload files to GCS from the frontend?</p>

<p>Thanks
Rob</p>

<p>If you will provide <code>gs_bucket_name</code> to <code>blobstore.create_upload_url</code> file will be stored in GCS instead of blobstore, this is described in official documentation: <a href="https://cloud.google.com/appengine/docs/python/blobstore/" rel="nofollow">Using the Blobstore API with Google Cloud Storage</a></p>

<pre><code>blobstore.create_upload_url(
                success_path=webapp2.uri_for('upload'),
                gs_bucket_name="mybucket/dest/location")
</code></pre>

<p>You can take a look at simple upload handler implementation made in webapp2 </p>

<pre><code>from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
import webapp2
import cloudstorage as gcs


class Upload(blobstore_handlers.BlobstoreUploadHandler):
    """Upload handler
    To upload new file you need to follow those steps:

    1. send GET request to /upload to retrieve upload session URL
    2. send POST request to URL retrieved in step 1
    """
    def post(self):
        """Copy uploaded files to provided bucket destination"""
        fileinfo = self.get_file_infos()[0]
        uploadpath = fileinfo.gs_object_name[3:]
        stat = gcs.stat(uploadpath)

        # remove auto generated filename from upload path 
        destpath = "/".join(stat.filename.split("/")[:-1])

        # copy file to desired location with proper filename 
        gcs.copy2(uploadpath, destpath)
        # remove file from uploadpath
        gcs.delete(uploadpath)

    def get(self):
        """Returns URL to open upload session"""

        self.response.write(blobstore.create_upload_url(
            success_path=uri_for('upload'),
            gs_bucket_name="mybucket/subdir/subdir2/filename.ext"))
</code></pre>

python google-app-engine google-cloud-storage