Writing byte stream as jpeg format to disk

Robert Kern robert.kern at gmail.com
Fri Aug 27 19:14:05 EDT 2010


On 8/27/10 5:58 PM, Lawrence D'Oliveiro wrote:
> In message
> <mailman.64.1282843346.29448.python-list at python.org>, Navkirat Singh wrote:
>
>> I receive a jpeg file with the POST method.The file (.jpeg) is encoded in
>> bytes, I parse the bytes by decoding them to a string. I wanted to know
>> how i could write the file (now a string) as a jpeg image on disk.
>
> I assume the JPEG data is received along with other field values in the
> POST. You’ll be saving those other fields in a database, right? So why not
> save the JPEG image there as well?

No, the only thing in the body of the POST are the bytes of the JPEG. He was 
incorrect in thinking that the JPEG data was arriving in the header. See the 
later posts in the thread for complete answers to his problem.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list