Force any methods that handle image uploading to open the image (for encoding) as a Binary file, was doing ASCII before (oddly, this wasn't caught until now. Major thanks to Yoav Aviram for pointing this out. :D

This commit is contained in:
Ryan McGrath 2009-09-06 15:48:58 -04:00
parent 34340248de
commit d6f6df2045
2 changed files with 4 additions and 4 deletions

View file

@ -1257,7 +1257,7 @@ class setup:
""" """
if self.authenticated is True: if self.authenticated is True:
try: try:
files = [("image", filename, open(filename).read())] files = [("image", filename, open(filename, 'rb').read())]
fields = [] fields = []
content_type, body = self.encode_multipart_formdata(fields, files) content_type, body = self.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}
@ -1278,7 +1278,7 @@ class setup:
""" """
if self.authenticated is True: if self.authenticated is True:
try: try:
files = [("image", filename, open(filename).read())] files = [("image", filename, open(filename, 'rb').read())]
fields = [] fields = []
content_type, body = self.encode_multipart_formdata(fields, files) content_type, body = self.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}

View file

@ -1257,7 +1257,7 @@ class setup:
""" """
if self.authenticated is True: if self.authenticated is True:
try: try:
files = [("image", filename, open(filename).read())] files = [("image", filename, open(filename, 'rb').read())]
fields = [] fields = []
content_type, body = self.encode_multipart_formdata(fields, files) content_type, body = self.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}
@ -1278,7 +1278,7 @@ class setup:
""" """
if self.authenticated is True: if self.authenticated is True:
try: try:
files = [("image", filename, open(filename).read())] files = [("image", filename, open(filename, 'rb').read())]
fields = [] fields = []
content_type, body = self.encode_multipart_formdata(fields, files) content_type, body = self.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}