Fix InputFile attribute check when from a BufferedReader object

This commit is contained in:
Leandro Toledo 2016-03-12 19:40:56 -03:00
parent 00f4328bab
commit 8ad34fc3c0

View file

@ -81,7 +81,8 @@ class InputFile(object):
self.input_file_content = self.input_file.read()
if 'filename' in data:
self.filename = self.data.pop('filename')
elif isinstance(self.input_file, file):
elif isinstance(self.input_file, file) and \
hasattr(self.input_file, 'name'):
self.filename = os.path.basename(self.input_file.name)
elif from_url:
self.filename = os.path.basename(self.input_file.url)\
@ -134,7 +135,7 @@ class InputFile(object):
form_boundary,
'Content-Disposition: form-data; name="%s"; filename="%s"' % (
self.input_name, self.filename
),
),
'Content-Type: %s' % self.mimetype,
'',
self.input_file_content