File

class bale.File(file_type, file_id, file_size, mime_type, bot, **kwargs)

Bases: object

This object shows a Base File Class.

file_type

Type of the file.

Type:

str

file_id

Identifier for this file, which can be used to download or reuse the file.

Type:

str

file_size

File size in bytes.

Type:

Optional[int]

mime_type

MIME type of the file as defined by sender.

Type:

Optional[str]

extra

The rest of the file information.

Type:

Optional[dict]

Note

You can get more information from the file with extra.

property base_file

Represents the Base File Class of this file

Type:

bale.File

async get()

For the documentation of the arguments, please see bale.Bot.get_file().

async save_to_memory(out)

Download this file into memory. out needs to be supplied with a io.BufferedIOBase, the file contents will be saved to that object using the io.BufferedIOBase.write() method.

Parameters:

out (io.BinaryIO) – A file-like object. Must be opened for writing in binary mode.

to_input_file()

Converts the file to a standard object for sending/uploading it. This object is require in the file sending methods.

Returns:

The bale.InputFile Object for send.

Return type:

bale.InputFile

property type

a Shortcut for use bale.File.file_type

Type:

str