Skip to content
Jingzhe

Files and Mini Apps

InputFile supports four sources:

Constructor Behavior
InputFile::file_id Reuse a file already stored by Telegram
InputFile::url Let Telegram download a remote file
InputFile::bytes Upload bytes held in memory
InputFile::path Read a local file with bounded access when explicitly requested

The complete protocol automatically discovers uploads at any nesting depth and creates separate multipart references for albums, media thumbnails, covers, rich messages, stickers, stories, and webhook certificates.

use jingzhe::{InputFile, SendDocument};
async fn send_document(bot: &Bot, chat_id: i64) -> jingzhe::Result<()> {
bot.request(SendDocument::new(chat_id, InputFile::path("report.pdf"))).await?;
Ok(())
}

The default upload and download limit is 20 MiB per file and can be adjusted:

let bot = bot.file_limits(50_000_000, 20_000_000)?;

Official per-method limits still apply. Local validation also limits images to 10 MB and thumbnails to 200 kB. Uploaded files are read into memory with a bound.

download returns the full byte buffer. download_to(&file, &mut writer).await? streams chunks into an async target without caching the entire file:

bot.download_to(&file, &mut writer).await?;

A failed download may leave partial output. The caller is responsible for flushing, atomic replacement, and cleanup.

The repository example examples/files.rs demonstrates InputFile::path, GetFile, download, and reusing a file_id.

Mini App entry points include:

  • InlineButton::web_app
  • KeyboardButton::web_app
  • MenuButton::WebApp
  • Menu settings
  • WebAppData
  • AnswerWebAppQuery
  • Prepared message and button save methods

Query results share the InlineQueryResult and InputMessageContent models. User input and Mini App data still require application validation.