-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload file to telegram servers and use it afterwards #1332
Comments
If you're using the bot to upload (literally send) // bot token
final String BOT_TOKEN = "123456xxxxxy";
// assign the client
TelegramClient telegramClient = new OkHttpTelegramClient(BOT_TOKEN);
// target chat id that file should be sent (String/Long)
final String CHAT_ID = "123456xxxxx";
// java.io.File (solid file) or String (URL to the target file) or String (file_id of the target file - your question)
final java.io.File FILE = new File("location");
// final String FILE = "https://example.com/targetFile";
SendDocument doc = SendDocument.builder()
.chatId(CHAT_ID)
.document(new InputFile(FILE))
.build();
// other doc settings
Message message = null;
try {
message = telegramClient.execute(doc);
} catch (TelegramApiException e) {
// handle the exception
}
if (message != null) {
String fileId = message.getDocument().getFileId();
// other operations
} Or, you can send your target file to the bot and get the update using the Now you have the Maybe this is out of the question, but you can use bots like Telegram Bot Raw to get the |
InputFile class have javadoc described "Input file used to upload a file to Telegram server and use it afterwards".
But how i can get file_id for uploaded file and use it afterwards for send user?
The text was updated successfully, but these errors were encountered: