download_media_to_memory()

Client.download_media_to_memory(message: Message | str, progress: callable | None = None, progress_args: tuple = ()) BytesIO | None

Download a media file directly into an in-memory BytesIO buffer.

Parameters:
  • message (Message | str) – Pass a Message object containing media or a file_id string.

  • progress (Callable, optional) – Pass a callback function to view the progress.

  • progress_args (tuple, optional) – Extra custom arguments for the progress callback.

Returns:

io.BytesIO | None – The BytesIO buffer holding downloaded binary data.

Download media directly into an in-memory io.BytesIO buffer.