Thursday, July 23, 2015

Re: How to use Python Requests Module to upload images to Django Application?


My Python code started working after I changed on line.

Changing:
     files_dct = {filename:fobj}
to:
    files_dct = {('photo',(filename, fobj,'image/jpg'))}

Now it works.  My conjecture about the need for different HTTP-headers was wrong.  The working code has not changed the headers received by Django.

I must say, the Requests module documentation is very opaque!

I made this change based on a guess while reading the docs about sending multiple files.  I can't say I understand what going on.

Please comment on the right way to do this. 




--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ab20873c-7e7e-4817-82f8-1a691a2cfa14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment