This repository was archived by the owner on May 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Google App Engine
blueimp edited this page May 20, 2011
·
37 revisions
To upload files to the Blobstore of Google App Engine, a new file upload url has to be created for every upload request.
On server-side you need to create a handler, which creates these upload urls and returns them as response to the browser request:
from google.appengine.ext import blobstore
from google.appengine.ext import webapp
class UploadUrlHandler(webapp.RequestHandler):
def get(self):
upload_url = blobstore.create_upload_url('/path/to/upload/handler')
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write('"' + upload_url + '"')
On client-side, you can override the add callback to retrieve the upload url and override the url setting, before adding the file to the upload queue:
$('#fileupload').fileupload({
add: function (e, data) {
var that = this;
$.getJSON('/upload-url-handler.json', function (url) {
data.url = url;
$.blueimpUI.fileupload.prototype
.options.add.call(that, e, data);
});
}
});
$.blueimpUI.fileupload is the widget class of jQuery File Upload UI. It extends the basic widget class of jQuery File Upload.
Documentation on how to create your own widget class based on the File Upload plugin can be found at the Plugin extensions page.