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 <danstic...@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-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.
>

-- 
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.

Reply via email to