telebot
telebot copied to clipboard
fileName when sendDocument
I have a trouble with the method bot.sendDocument, it don't put the filename as expected.
bot.sendDocument(msg.chat.id,'someurl',{
caption:'foo',
fileName:'MYNAME'}
);
I receive the pdf on the chat, that's fine but the file name is '.pdf' not 'MYNAME.pdf'
As far as the Telegram Bot API, there is no way to pass a custom file name when passing its URL sendDocument.
After a quick look at Telebot code, seems that the filename option is used when sending a file using multipart/form-data, which happens if you pass a Stream, Buffer, a local file path or set serverDownload option when calling bot.sendDocument.
You can try this just to see if what I just said makes sense. Note however that with the below code, it's your server that downloads the file, not Telegram servers:
bot.sendDocument(msg.chat.id,'someurl',{
caption:'foo',
fileName:'MYNAME',
serverDownload:true}
);
However, not sure why you are seeing .pdf as the file name and not something else.
Hope this helps.