file_id from a received message to download its attachment. The method writes to disk by default and returns the saved path.
file_name is omitted, the name from Telegram is used. If download_path is omitted, telegram.current_directory is used.
Keep the file in memory
Setas_bytes = True to return the file contents instead of writing a file:
Tune streaming and timeouts
Downloads are streamed in chunks. You can change the chunk size and override the client timeout for one download:429) and server-error (5xx) responses are retried automatically, respecting the client’s max_flood_retries setting. Timeouts raise TelegramTimeoutError; other network failures raise TelegramNetworkError.
Change the default directory
current_directory is used whenever download_path is omitted. You can change it at any time:
Disk downloads are written to a temporary
.part file and moved into place only after the download completes.