Goodnight.

I am writing a Telegram client for Android based on the Kotlogram library, and I encountered the following problem. I have to upload a list of dialogs for the user, this case is in the examples of this library. But, besides the chats themselves, I need to get their images to be displayed in the list. All evening trying to solve this problem, but nothing comes out. The maximum result I could achieve is to save the image locally. I got it as follows:

TelegramClient client = Kotlogram.getDefaultClient(application, new ApiStorage()); TLUserFull user = User.getUser(client, telegramMessageEvent.getFromId()); TLPhoto photo = user.getProfilePhoto().getAsPhoto(); MediaInput mediaInput = TLMediaUtilsKt.getMediaInput(TLMediaUtilsKt.getMaxSize(photo.getSizes())); FileOutputStream fos = new FileOutputStream(new File("C:/TEMP", "test.png")); client.downloadSync(mediaInput.getInputFileLocation(), mediaInput.getSize(), fos); 

But it does not suit me. The best option would be to get a direct link to this image. As I understand it, in the Telegram API you cannot do it as in the Telegram Bot API via the link of the form:

 https://api.telegram.org/file/bot<token>/<file_path> 

Rummaging in the network, I found one option from another library:

 BufferedImage img = ImageIO.read(new ByteArrayInputStream(file.getBytes().getData())); 

where file is TLFile .

In the library itself there is a method, for example,

 client.getUserPhoto(user); 

which returns just an object of type TLFile . I don’t know if this option would work or not, but the above method fails

400: LIMIT_INVALID

I understand that this error means that there is a request for a file that weighs more than 1Mb. And in this case, it would be necessary to break it apart, but I found such functionality only in the method

 client.downloadSync() 

The default is 512Kb.

As far as I looked, the libraries on the basis of the Telegram API for various platforms are similar in structure. Therefore, I would like to know how you can get a direct link to the image via the Telegram API or, in extreme cases, an object containing the image itself. Saving the file to memory for its further reading does not suit me at all.

Thank you in advance.

    0