InputFile¶
Типы файлов для загрузки.
InputFile (базовый)¶
class InputFile(ABC):
def __init__(
self,
filename: str | None = None,
chunk_size: int = DEFAULT_CHUNK_SIZE, # 64 * 1024
) -> None: ...
@abstractmethod
async def read(self, bot: Bot) -> AsyncGenerator[bytes, None]: ...
BufferedInputFile¶
Загрузка из байтов в памяти.
class BufferedInputFile(InputFile):
def __init__(
self,
file: bytes,
filename: str,
chunk_size: int = DEFAULT_CHUNK_SIZE,
) -> None: ...
@classmethod
def from_file(
cls,
path: str | Path,
filename: str | None = None,
chunk_size: int = DEFAULT_CHUNK_SIZE,
) -> BufferedInputFile: ...
Атрибут data: bytes — содержимое файла.
FSInputFile¶
Асинхронная потоковая загрузка из файловой системы.
class FSInputFile(InputFile):
def __init__(
self,
path: str | Path,
filename: str | None = None,
chunk_size: int = DEFAULT_CHUNK_SIZE,
) -> None: ...
Атрибут path: str | Path — путь к файлу. Читает файл через aiofiles.
URLInputFile¶
Потоковая загрузка из URL.
class URLInputFile(InputFile):
def __init__(
self,
url: str,
headers: dict[str, Any] | None = None,
filename: str | None = None,
chunk_size: int = DEFAULT_CHUNK_SIZE,
timeout: int = 30,
bot: Bot | None = None,
) -> None: ...
Атрибуты:
url: str— URL для загрузкиheaders: dict— HTTP-заголовкиtimeout: int— таймаут в секундах
Константы¶
Исходный файл¶
maxgram/types/input_file.py