X Tutup
Skip to content

Commit 82030c4

Browse files
committed
Merge pull request python-telegram-bot#199 from python-telegram-bot/send-inputfile-from-bytesio
Fix InputFile attribute check when from a BufferedReader object
2 parents 25595e6 + 8ad34fc commit 82030c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

telegram/inputfile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def __init__(self,
8181
self.input_file_content = self.input_file.read()
8282
if 'filename' in data:
8383
self.filename = self.data.pop('filename')
84-
elif isinstance(self.input_file, file):
84+
elif isinstance(self.input_file, file) and \
85+
hasattr(self.input_file, 'name'):
8586
self.filename = os.path.basename(self.input_file.name)
8687
elif from_url:
8788
self.filename = os.path.basename(self.input_file.url)\
@@ -134,7 +135,7 @@ def to_form(self):
134135
form_boundary,
135136
'Content-Disposition: form-data; name="%s"; filename="%s"' % (
136137
self.input_name, self.filename
137-
),
138+
),
138139
'Content-Type: %s' % self.mimetype,
139140
'',
140141
self.input_file_content

0 commit comments

Comments
 (0)
X Tutup