multipart support utf-8
This commit is contained in:
parent
e216e4a627
commit
aaf5990381
1 changed files with 9 additions and 0 deletions
|
@ -19,11 +19,20 @@ class MultiPartForm(object):
|
||||||
|
|
||||||
def add_field(self, name, value):
|
def add_field(self, name, value):
|
||||||
"""Add a simple field to the form data."""
|
"""Add a simple field to the form data."""
|
||||||
|
if isinstance(name, unicode):
|
||||||
|
name = name.encode('utf-8')
|
||||||
|
if isinstance(value, unicode):
|
||||||
|
value = value.encode('utf-8')
|
||||||
self.form_fields.append((name, value))
|
self.form_fields.append((name, value))
|
||||||
return
|
return
|
||||||
|
|
||||||
def add_file(self, fieldname, filename, fileHandle, mimetype=None):
|
def add_file(self, fieldname, filename, fileHandle, mimetype=None):
|
||||||
"""Add a file to be uploaded."""
|
"""Add a file to be uploaded."""
|
||||||
|
if isinstance(fieldname, unicode):
|
||||||
|
fieldname = fieldname.encode('utf-8')
|
||||||
|
if isinstance(filename, unicode):
|
||||||
|
filename = filename.encode('utf-8')
|
||||||
|
|
||||||
if hasattr(fileHandle, 'read'):
|
if hasattr(fileHandle, 'read'):
|
||||||
body = fileHandle.read()
|
body = fileHandle.read()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue