mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Support .name attr in utils.is_type/client.upload_file
This means open()'ed files will have their name used properly, and that you can set b.name = 'somename.jpg' to io.BytesIO() objects to have them uploaded as images.
This commit is contained in:
@@ -270,6 +270,9 @@ class UploadMethods(MessageParseMethods, UserMethods):
|
||||
if isinstance(file, (types.InputFile, types.InputFileBig)):
|
||||
return file # Already uploaded
|
||||
|
||||
if not file_name and getattr(file, 'name', None):
|
||||
file_name = file.name
|
||||
|
||||
if isinstance(file, str):
|
||||
file_size = os.path.getsize(file)
|
||||
elif isinstance(file, bytes):
|
||||
|
Reference in New Issue
Block a user