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:
Lonami Exo
2018-06-21 16:31:03 +02:00
parent d8af64e3b9
commit 3973755333
2 changed files with 21 additions and 8 deletions

View File

@@ -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):