How to handle uploaded files in webapp2

google-app-engine, python, webapp2

Solution

You can use `enctype="multipart/form-data"` in your form, and then get file content by using in your handler:

raw_file = self.request.get('field_name')

Then, pass raw_file as input to your model's property.

Problem

Google appengine's webapp2 has a very cryptic documentation regarding the handling of uploaded files. ``` Uploaded files are available as cgi.FieldStorage (see the cgi module) instances directly in request.POST. ``` I have a form which makes a POST request of JSON files which I want to store in an NDB.JsonProperty. Can anyone offer a short example of how do I read the file from the request object?

Original source

Related problems