mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-23 06:50:29 +01:00
Fix InputFile attribute check when from a BufferedReader object
This commit is contained in:
parent
00f4328bab
commit
8ad34fc3c0
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue