Writing byte stream as jpeg format to disk

Robert Kern robert.kern at gmail.com
Thu Aug 26 15:40:30 EDT 2010


On 8/26/10 1:25 PM, Navkirat Singh wrote:
>
> On 26-Aug-2010, at 11:01 PM, John Bokma wrote:
>
>> Navkirat Singh<navkirats at gmail.com>  writes:
>>
>>> Hey guys,
>>>
>>> I am programming a webserver, 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.
>>
>> Why?
>>
>> --
>> John Bokma                                                               j3b
>>
>> Blog: http://johnbokma.com/    Facebook: http://www.facebook.com/j.j.j.bokma
>>     Freelance Perl&  Python Development: http://castleamber.com/
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
> why? I am not quite sure what you have not understood.

Why decode the bytes to (presumably) unicode strings just to encode them back to 
bytes again? JPEG is not composed of unicode characters; you need to leave them 
as bytes.

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