From 9195bccb41695a8f47218bc80b0458af821eafbd Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 6 Aug 2018 18:03:42 +0200 Subject: [PATCH] Fix sending files from disk after 6d1bc22 (#941 and #943) --- telethon/client/uploads.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index 8bf3c48e..6854a669 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -393,7 +393,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods): file_handle = None as_image = utils.is_image(file) and not force_document use_cache = types.InputPhoto if as_image else types.InputDocument - if not isinstance(file, str): + if not isinstance(file, str) or os.path.isfile(file): file_handle = await self.upload_file( file, progress_callback=progress_callback, use_cache=use_cache if allow_cache else None @@ -412,6 +412,11 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods): if media: pass # Already have media, don't check the rest + elif not file_handle: + raise ValueError( + 'Failed to convert {} to media. Not an existing file, ' + 'an HTTP URL or a valid bot-API-like file ID'.format(file) + ) elif isinstance(file_handle, use_cache): # File was cached, so an instance of use_cache was returned if as_image: