phpbotgram

FsInputFile extends InputFile
in package

FinalYes

Standalone abstract — InputFile is intentionally NOT a TelegramObject. Upstream aiogram declares `class InputFile(ABC)` (aiogram/types/input_file.py); attaching it to the TelegramObject tree would make it eligible for Serializer dump/load, which is wrong: InputFile values are detached by `BaseSession::prepareValue` into the multipart `$files` channel and never go through JSON.

Table of Contents

Constants

DEFAULT_CHUNK_SIZE  : int = 65536

Properties

$chunkSize  : int
$filename  : string|null
$path  : string

Methods

__construct()  : mixed
Phase 1 caveat: $chunkSize is recorded on the parent but ignored by read() — the buffered read uses file_get_contents and returns a single ReadableBuffer.
read()  : ReadableStream
Reads the file fully into memory then wraps it in a ReadableBuffer.

Constants

DEFAULT_CHUNK_SIZE

public int DEFAULT_CHUNK_SIZE = 65536

Properties

$chunkSize read-only

public int $chunkSize = self::DEFAULT_CHUNK_SIZE

$filename read-only

public string|null $filename = null

Methods

__construct()

Phase 1 caveat: $chunkSize is recorded on the parent but ignored by read() — the buffered read uses file_get_contents and returns a single ReadableBuffer.

public __construct(string $path[, string|null $filename = null ][, int $chunkSize = self::DEFAULT_CHUNK_SIZE ]) : mixed

Phase 6 replaces the buffered path with a true streaming reader that honours the configured chunk size.

Parameters
$path : string
$filename : string|null = null
$chunkSize : int = self::DEFAULT_CHUNK_SIZE

read()

Reads the file fully into memory then wraps it in a ReadableBuffer.

public read(Bot $bot) : ReadableStream

The previous implementation used Amp\File\openFile() which spawns an amphp/parallel worker process. The worker's destructor (during PHP shutdown) tries to reference a callback on an EventLoop driver that RunAsyncTrait::resetEventLoop() has already replaced, producing a fatal "Invalid callback identifier" and exit code 255 in CI.

For Phase 1 the typical Telegram file size (photos/voice/docs under ~50 MB) fits comfortably in memory; the buffered path is simpler and has no worker-cleanup race. If truly streaming uploads matter later, Phase 5+ can swap in a Fiber-friendly file driver that doesn't go through amphp/parallel.

Parameters
$bot : Bot
Return values
ReadableStream
On this page

Search results