Skip to content

Commit 8ad34fc

Browse files
committed
Fix InputFile attribute check when from a BufferedReader object
1 parent 00f4328 commit 8ad34fc

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy