Figured it out (finally!). I had been logging elements of the request (params, body, etc.) as I sorted through other issues. But you can only instantiate a cgi.FieldStorage element once, so by the time I got to the actual self.request.get('user_file'), it was already gone.
Classic case in which removing the debugging actually makes it work. On Tuesday, April 22, 2014 2:34:44 PM UTC-7, Devel63 wrote: > > Nope. As I mentioned, self.request.POST is UnicodeMultiDict([]). > > On the other hand, self.request.params appears to have everything, but I > cannot get at the dictionary entry, as described below. > > > On Tuesday, April 22, 2014 2:16:19 PM UTC-7, paddycarey wrote: >> >> I think this should work: >> >> file_content = self.request.POST.multi['user_file'].file.read() >> >> Paddy >> >> >> On Tue, Apr 22, 2014 at 9:40 PM, Devel63 <danst...@gmail.com> wrote: >> >>> The documentation makes it appear very simple to get the contents of an >>> uploaded file, but while I can do this with old_dev_appserver.py, I cannot >>> get it with the current dev_appserver.py (v1.9.2). >>> >>> Here's a simple example: >>> >>> <form name="myform" action="http://localhost:8080/sync?cmd=tester" >>> enctype="multipart/form-data" method="post"> >>> >>> Username: <input type="file" name="user_file" /> >>> <input type="submit" value="Submit" /> >>> >>> </form> >>> >>> >>> - In old_dev_appserver.py, one could get the file in GAE via >>> self.request.get('user_file'), but not with dev_appserver.py >>> >>> >>> - WebApp2 >>> <http://webapp-improved.appspot.com/guide/request.html#files>says >>> "Uploaded >>> files are available as cgi.FieldStorage (see the >>> cgi<http://docs.python.org/2.7/library/cgi.html#cgi> module) >>> instances directly in request.POST." But, request.POST is empty, >>> and cgi.FieldStorage() does not contain 'user_file' either. >>> >>> Strangely, if I print out self.request.params, I do see an element in >>> the UnicodeMultiDict that is (u'user_file', FieldStorage(u'user_file', >>> u'myfile.ico')). But when I try to get that element, either via named >>> access or just iterating over params, I cannot get it. Even if I do a >>> Len(self.request.params) I get one less than what I see, and the >>> 'user_file' element is missing. If I do this with old_dev_appserver, the >>> Len(self.request.params) is correct. >>> >>> How do I get user_file? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google App Engine" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to google-appengi...@googlegroups.com. >>> To post to this group, send email to google-a...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/google-appengine. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/d/optout.