Upload Files with the AppEngine

If you want process an uploaded file in a cgi-programm, you often need to juggle with temporary files. How to do it with the Python in the AppEngine? Because you don’t have write access to a traditonal file system in this highly distrubuted environment. I have searched a while in the documentation. Finally, in an example for picture processing, I found the solution.

It was just too easy. If you have a HTML input field of type “file” with the name “Uploadfile”, you can access the uploaded data like this:

filecontent = self.request.get ( 'Uploadfile')

Then the file content is then stored in the variable “filecontent”. If it happens to be a text file, You can process it like a normal string.

For many applications this is and sufficient and very convenient. A few questions are still open for me:

  • How to get the original filename?
  • If the uploaded file is very big, how can I block further processing as early as possible?

Leave a comment