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! V
On Thu, Oct 8, 2009 at 11:43 AM, Gabriel Genellina <gagsl-...@yahoo.com.ar>wrote: > En Thu, 08 Oct 2009 12:30:16 -0300, Victor Subervi < > victorsube...@gmail.com> escribió: > > http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1 >> >> On Wed, Oct 7, 2009 at 4:11 PM, Rami Chowdhury <rami.chowdh...@gmail.com >> >wrote: >> >> On Wed, 07 Oct 2009 14:05:25 -0700, Victor Subervi < >>> victorsube...@gmail.com> wrote: >>> >>> print 'Content-Type: image/jpeg' >>> >>>> print 'Content-Encoding: base64' >>>> print >>>> print content.encode('base64') >>>> >>> > Are you sure this is your actual code? > > py> import urllib > py> data = urllib.urlopen(" > http://13gems.com/stxresort/cart/getpic1.py?id=1&x=1").read() > py> data[:30] > 'Content-Encoding: base64\n\n\n/9j' > py> data[-30:] > 'XdjTJvaaF5fvfMVgbUM+gatZXFzb\n\n' > > 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) > 65535 > py> decoded[:30] > '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x02\x01\x00H\x00H\x00\x00\xff\xe1 > \xadExif\x00\x00' > > 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 > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list