I have been trying to use an ajax-style file upload component (like the dojox file upload component) with google app engine, and have a progress bar.
The javascript side of things is fine, but i am wondering how to organise things on the server side?
Is is possible to access the data as it is being uploaded within google app engine, something with BaseHTTPServer perhaps? I could then poll this from the client.
Even if it wasn't possible to do the progress, at least it would be great to be able to terminate a large file and let the user know it was to big without making the user upload 1MB (the google app engine limit) and then find out it was to big.
There are some similar questions: Similar stack overflow question 1, Similar stack overflow question 2.
The following google app engine python code is just the basic post handler for a simple file upload (which works fine) but im looking for something that operates at a bit of a lower level. By the time the post handler gets it, the file has all been uploaded.
On a LAMP stack you can poll a server side script that watches a temporary file size grow. When the file is moved from the temporary folder you know its completed. By using this method you can see the progress of multiple files without the use of flash, I'm not sure how to do the same thing with google app engine.
class fileupload(webapp.RequestHandler):
"""
"""
def post(self):
if "image" in self.request.arguments():
content = "<html><body>Error</body></html>"
form = self.request.params['image']
logging.info(form)
try:
filename = form.filename
siz = len(form.value)
###--- Show data
logging.info("Filename: %s" % form.filename)
logging.info("Size: %s" % siz)
content = "<html><body>File has been uploaded Name: %s Size: %s</body></html>" % (filename, siz)
logging.info("DONE")
except:
logging.info("Error: bad form or something like that")
logging.info("writing out response")
self.response.out.write(content)