save_file()

Client.save_file()

Upload a file onto Telegram servers, without actually sending the message to anyone.

Useful whenever an InputFile type is required.

Usable by Users Bots
Parameters:
  • path (``str`` | ``BinaryIO``) – The path of the file you want to upload that exists on your local machine or a binary file-like object with its attribute “.name” set for in-memory uploads.

  • file_id (``int``, *optional*) – In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.

  • file_part (``int``, *optional*) – In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.

  • progress (``Callable``, *optional*) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.

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

Returns:

``InputFile | InputFileBig`` (On success, the uploaded file is returned.)

Raises:

RPCError – In case of a Telegram RPC error.: