pengrad / java-telegram-bot-api

Telegram Bot API for Java
https://core.telegram.org/bots
Apache License 2.0
1.79k stars 372 forks source link

Photo message #27

Closed Psychevus closed 8 years ago

Psychevus commented 8 years ago

How can I download image via this java-telegram-bot-api? I got a response that contains Message model. now I want to get to the Image file, how can I do this?

pengrad commented 8 years ago

Take photo from message and execute GetFile request.

Psychevus commented 8 years ago

I create instance from GetFile(file_id). but I cant still figure that out. how to get a file from getFile?

GetFile getFile = new GetFile(message.photo()[0].fileId());

pengrad commented 8 years ago
GetFileResponse response = bot.execute(getFile);
File file = response.file;

If u want to get full path of file to download, use: String urlPath = bot.getFullFilePath(file)

Psychevus commented 8 years ago

Thank you @pengrad :+1: :)