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

SendDocument didn't change file name and use always file.txt #47

Closed rostislav-maslov closed 8 years ago

rostislav-maslov commented 8 years ago

Steps to reproduce:

  1. Try to use code:
public void sendDocument(chanId, byte[] fileBytes){
        File temp = File.createTempFile("My own file name", ".pdf");
        FileUtils.writeByteArrayToFile(temp, fileBytes);

        SendDocument sendDocument = new SendDocument(chatId, temp);
        sendDocument.caption("My own file name caption.pdf");
        bot.execute(sendDocument);

        temp.delete();

}
  1. Run code
  2. Get file with name "file.txt"

Expected result: File with name "My own file name.pdf" or "My own file name caption.pdf"

Actual result: File with name "file.txt"

rostislav-maslov commented 8 years ago

Hi @pengrad ,

Thanks for ur library, it's so helpful. Please feel free to write to me if you have any questions.

rostislav-maslov commented 8 years ago

I'm using version 2.1.1

pengrad commented 8 years ago

Hi! I can not reproduce. I have correct file name with your code. Anyway you can explicitly call fileName("my file name") on sendDocument request. See https://github.com/pengrad/java-telegram-bot-api/issues/32

rostislav-maslov commented 8 years ago

My bad, using 2.1.0 instead of 2.1.1