-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
The current signature is as follows:
def download(self, custom_path=None, out=None, timeout=None):
"""
Download this file. By default, the file is saved in the current working directory with its
original filename as reported by Telegram. If a :attr:`custom_path` is supplied, it will be
saved to that path instead. If :attr:`out` is defined, the file contents will be saved to
that object using the ``out.write`` method.
...
This some_file.download(...)
method does not allow inspection on the saved file.
Since the download location is computed at runtime and dependant on the "original filename as reported by Telegram", you need to replicate the path calculations which were done in the method to have access to the downloaded file after calling it. So if you actually want to keep this original filename as reported by Telegram (for example because you cannot be sure about the file extension), there's no easy way to do that.
One-liners like
out_file = bot.get_file(update.effective_message.photo).download(custom_path="/some/path")
do_something_with(out_file)
are not possible.
Since the .download() method doesn't return any useful value at the moment, I suggest to let it return either a handle or the filepath to the created file.