How Telegram Mini Apps Create and Download Files: In-App Document Generation, PDF Exports & Direct Storage
Turn Telegram Mini Apps into full-fledged business and utility workstations. Explore how Mini Apps generate custom invoices, contracts, financial spreadsheets, and AI artwork on the fly, saving them directly to your device's native filesystem with zero browser redirection.
Export purchase invoices, tickets, certificates, and legal contracts directly from inside your Mini App session.
Files save directly into your device's Downloads folder or iOS Files app using Telegram's native background download manager.
Export JSON game saves, CSV financial reports, or ZIP media archives for complete data ownership and local portability.
storage Architecture: Overcoming the Webview File Download Limitation
blob: URLs or base64 streams) often fails or requires opening external Safari or Chrome tabs, breaking user immersion.
Telegram Mini Apps 2.0 introduces the native downloadFile API. When a Mini App creates a document, image, or archive, Telegram handles the download via its native operating system bridge. A discreet system banner prompts the user with the file size and filename, saving the asset directly to local storage in the background.
developer_mode Developer SDK: downloadFile Implementation
// Generate and download a report inside Telegram Mini App
if (window.Telegram.WebApp.downloadFile) {
window.Telegram.WebApp.downloadFile({
url: "https://api.myapp.com/export/invoice_9482.pdf",
file_name: "Invoice_Nov_2024.pdf"
}, function(accepted) {
if (accepted) {
console.log("User confirmed file download");
} else {
console.warn("User cancelled download");
}
});
}
Test how a Telegram Mini App prepares and exports a formatted PDF document to your device's native download queue.
help Frequently Asked Questions
No. Telegram requires explicit confirmation for every download. When a Mini App calls downloadFile, a native confirmation modal appears displaying the filename, extension, and file size. The download only proceeds when you tap “Download”.
On Android, files are placed directly in your device's standard Downloads directory. On iOS, files are accessible through the native Files app under the Telegram or Downloads folder, and can be opened in any document viewer.