On Mon, Aug 22, 2016 at 11:14 AM, Michal Petrucha
<michal.petru...@koniiiik.org> wrote:
> On Mon, Aug 22, 2016 at 11:10:38AM -0400, Larry Martell wrote:
>> On Mon, Aug 22, 2016 at 11:00 AM, Michal Petrucha
>> <michal.petru...@koniiiik.org> wrote:
>> > On Mon, Aug 22, 2016 at 10:11:49AM -0400, Larry Martell wrote:
>> >> When I get the request, request.FILES is empty. Yet the content type
>> >> is multipart/form-data and the method is POST:
>> >>
>> >> (Pdb) print request.META['CONTENT_TYPE']
>> >> multipart/form-data;
>> >> boundary="boundary_.oOo._NzEwNjIzMTM4MTI4NjUxOTM5OQ==MTY2NjE4MDk5Nw=="
>> >>
>> >> (Pdb) print request.META['REQUEST_METHOD']
>> >> POST
>> >>
>> >> (Pdb) print request.FILES
>> >> <MultiValueDict: {}>
>> >>
>> >> The individual files are being sent with content-type
>> >> 'application/octet-stream', and it looks like I get the contents of
>> >> the files converted to unicode:
>> >>
>> >> (Pdb) 
>> >> type(request.POST['right-carotidartery:63B2E474-D690-445F-B92A-31EBADDC9D93.png'])
>> >> <type 'unicode'>
>> >
>> > Are you certain the request contains correct headers for files? In
>> > particular, look at the “Content-Disposition” header; for each file,
>> > it should contain the “filename” attribute; otherwise, Django will
>> > treat it as a regular (non-file) form field [1]. As an example, the
>> > header could look like this::
>> >
>> >     Content-Disposition: form-data; name="file"; filename="filename.png"
>>
>> How would I access the Content-Disposition for each file? In the
>> headers for the request that field does not exist.
>
> What I'm suggesting is that you look at the raw HTTP request that's
> going over the wire, or investigate the client that's making the
> request. I'm not sure if there's any reasonable way to work around
> this on the Django side.

Thanks so much. I solved this by changing the client to set the file
and filename fields each part of the multipart and then I was able it
iterate through request.FILES and successfully write the files as PNG.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5dniP3VxdN8op4J9GSsFRv1KPZqM0NLaf1Fi8caoBK9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to