Problem Displaying Pics
victorsubervi at gmail.com
Thu Oct 8 20:06:26 CEST 2009
I have come to the conclusion that this has absolutely nothing to do with
the code. The problem is eNom. I have had so many problems with this
provider specifically concerning their python interpreter that I actually
filed a complaint against them with the BBB, which they still didn't
resolve. Now that I'm back in the states and making money, I've bought space
on another server that I'm building. Let me spend my time building that, and
I believe all these silly problems will go away. I will start a new thread
if I'm wrong. Thank you all for your help!
On Thu, Oct 8, 2009 at 11:43 AM, Gabriel Genellina
<gagsl-py2 at yahoo.com.ar>wrote:
> En Thu, 08 Oct 2009 12:30:16 -0300, Victor Subervi <
> victorsubervi at gmail.com> escribió:
>> On Wed, Oct 7, 2009 at 4:11 PM, Rami Chowdhury <rami.chowdhury at gmail.com
>> On Wed, 07 Oct 2009 14:05:25 -0700, Victor Subervi <
>>> victorsubervi at gmail.com> wrote:
>>> print 'Content-Type: image/jpeg'
>>>> print 'Content-Encoding: base64'
>>>> print content.encode('base64')
> Are you sure this is your actual code?
> py> import urllib
> py> data = urllib.urlopen("
> py> data[:30]
> 'Content-Encoding: base64\n\n\n/9j'
> py> data[-30:]
> 1) The Content-Encoding line is taken as part of the response entity (the
> picture data), but should be part of the header. I bet you have a blank line
> after Content-Type.
> 2) Note the \n\n at the end
> py> data = data[27:-2]
> py> decoded = data.decode("base64")
> py> open("test.jpg","wb").write(decoded)
> I tried to open test.jpg, but it's corrupt.
> py> len(decoded)
> py> decoded[:30]
> Very suspicious file size... Looks like a jpeg image that was truncated at
> that size. See whether it is already corrupt in the database and repair it
> (you're using a data type large enough to hold the image, aren't you?)
> After fixing the database, you can omit the unnecesary base64 encoding;
> anyway I'd add a Content-Length header to avoid that spurious \n at the end.
> Gabriel Genellina
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list