1
votes

I had to store files which had sizes to the north of 1MB and google app engine advised that I should store them in Google Cloud Storage. The app engine BlobProperty was not suitable.

The section Using Blobstore API with Google Cloud Storage advises to use, create_upload_url function's gs_bucket_name parameter.

I tried it.

gcs_upload_url = blobstore.create_upload_url('/myupload', gs_bucket_name='bucketname.appspot.com/')

The resultant URL that I get for the POST is not /myupload, It goes somewhat like

<form action="http://myapp.appspot.com/_ah/upload/XXXXXXXXXXX7NNN-XXXXYYY/" method="post" enctype="multipart/form-data">

I have changed the part after /upload/, but the point is, it clearly misses creating a proper upload URL, which can be recognized by my handler.

What's the correct way to use create_upload_url with gs_bucket_name and also get the correct URL for handing the post?

Clearly the official documentation is not helpful here.

2

2 Answers

3
votes

The path you passed in create_upload_url function is success_path. See description below.

The URL path of the request handler that will process the upload request, after the file submitted with the form has been uploaded to the Blobstore.

The success_path is called by App Engine after the file has been uploaded into BlobStore or Google Cloud Storage.

When the user submits an upload web form, the uploaded data goes directly to the Blobstore or to Google Cloud Storage if you use that instead of Blobstore. (Google Cloud Storage requires the gs_bucket_name parameter.) The Blobstore rewrites the incoming request to remove the uploaded data (the MIME part body) and add the Blobstore key (as a header in the MIME part), then passes the rewritten request to the application handler associated with the URL path given to create_upload_url() as success_path. The handler at that path can process the rest of the form.

The URL provided by this function is intended to be used as the action of your upload form. The path provided by you is something like post-upload handler.

2
votes

That is the correct way. The upload URL is handled by AppEngine itself: it will accept the file upload, then call your own handler directly.