O
O
Oleg Carp2020-12-03 20:29:17
Java
Oleg Carp, 2020-12-03 20:29:17

How to send a file link for downloading on the telegram side in telegram java api?

Download link from google drive, tried it with a link to download the VK file - the same thing
If I download the file on my server and send a telegram, then everything is ok

SendDocument sendDocument = new SendDocument();
        String urlDownload = task.getSolution();
        sendDocument.setChatId(idChat);
        sendDocument.setDocument(downloadFile(urlDownload, task.getFileName()));

I'm trying to upload a file on the telegram side,
but I get an error Error sending document, the file does not even weigh 1kb
String urlDownload = task.getSolution();
        sendDocument.setChatId(idChat);
        sendDocument.setDocument(new InputFile().setMedia(urlDownload));

although there were no problems with loading the image in this way.
new InputMediaPhoto().setMedia(urlCoverBook);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BohdanNoname, 2021-01-15
@BohdanNoname

In my case, the error usually popped up when I tried to send a file/message without the execute() method. It's worth trying to send a file like this:
execute(sendDocument(nameOfFile, new InputFile(url + fomatFile));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question