Skip to content

DownloadingFiles

literallyfiro edited this page Feb 10, 2026 · 2 revisions

Downloading Files

The FileDownloader interface in TeleightBots provides methods to download files from Telegram. This can be useful for bots that need to handle media files, documents, or any other type of file that users send.

You can use the bot.getFileDownloader().downloadFile(..) methods to download a file from Telegram. Every method returns a CompletableFuture that will complete with the downloaded java.io.File.

bot.getFileDownloader().downloadFile(filePath).thenAccept(file -> {
    System.out.println("File downloaded to: " + file.getAbsolutePath());
}).exceptionally(ex -> {
    System.err.println("Failed to download file: " + ex.getMessage());
    return null;
});

Clone this wiki locally