yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.17k stars 1.5k forks source link

Question: how to send docx file using sendDocument #1081

Closed jstdk closed 1 year ago

jstdk commented 1 year ago

Question

Is it possible to send a docx file using sendDocument? It always arrives as data.zip (with some xml stuff in that unzipped folder, but no docx file). I have tried the following:

  1. send as online URL (total failure)
  2. send as buffer (data.zip file instead of docx file)
  3. Checked online documentation from Telegram or other SO posts (none)
  4. Added fileOptions as follows:

image

Thanks for suggestions

jstdk commented 1 year ago

Figured it out, but a bit ugly. I converted the buffer to a real file, then created a stream of the file and then send the message. After sending message, I remove the local file. Its like going from New York to LA via Tokyo, but it works.