- class telegram.File(*args, **kwargs)¶
This object represents a file ready to be downloaded. The file can be downloaded with
download. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling
Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their
Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.
- async download(custom_path=None, out=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_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 the file has no filename, it the file ID will be used as filename. If a
custom_pathis supplied, it will be saved to that path instead. If
outis defined, the file contents will be saved to that object using the
Changed in version 20.0:
The same object as
outif specified. Otherwise, returns the filename downloaded to or the file path of the local file.
- Return type
- async download_as_bytearray(buf=None)¶
Download this file and return it as a bytearray.