-
Notifications
You must be signed in to change notification settings - Fork 7
DownloadingFiles
literallyfiro edited this page Feb 10, 2026
·
2 revisions
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;
});