telegram.InputFile

class telegram.InputFile(obj, filename=None, attach=None)

Bases: object

This object represents a Telegram InputFile.

input_file_content

bytes – The binaray content of the file to send.

filename

str – Optional, Filename for the file to be sent.

attach

str – Optional, attach id for sending multiple files.

Parameters:
  • obj (File handler) – An open file descriptor.
  • filename (str, optional) – Filename for this InputFile.
  • attach (bool, optional) – Whether this should be send as one file or is part of a collection of files.
Raises:

TelegramError

static is_image(stream)

Check if the content file is an image by analyzing its headers.

Parameters:stream (str) – A str representing the content of a file.
Returns:The str mime-type of an image.
Return type:str