Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff0dd8e

Browse files
committed
Patch for an Issue #997
1 parent bd99470 commit ff0dd8e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

thirdparty/multipart/multipartpost.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ def multipart_encode(vars, files, boundary = None, buf = None):
8888
for (key, fd) in files:
8989
file_size = os.fstat(fd.fileno())[stat.ST_SIZE] if isinstance(fd, file) else fd.len
9090
filename = fd.name.split('/')[-1] if '/' in fd.name else fd.name.split('\\')[-1]
91-
contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
91+
try:
92+
contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
93+
except:
94+
# Reference: http://bugs.python.org/issue9291
95+
contenttype = 'application/octet-stream'
9296
buf += '--%s\r\n' % boundary
9397
buf += 'Content-Disposition: form-data; name="%s"; filename="%s"\r\n' % (key, filename)
9498
buf += 'Content-Type: %s\r\n' % contenttype

0 commit comments

Comments
 (0)