elbekD / kt-telegram-bot

Telegram Bot Library for Kotlin language
MIT License
103 stars 19 forks source link

How to send ByteArray (or OutputStream) as a file? #64

Open SonicNorg opened 5 months ago

SonicNorg commented 5 months ago

Hi, I have a byte array with content and would like to send it as a file without saving it anywhere on a file system. Could you please provide an example of how to do it? Thank you in advance.

This com/elbekD/bot/http/TelegramClient.kt:128 sender always sets the filename as "content" when trying to send ByteArray. This is unacceptable because I can't specify the file extension and let the user open it.

when (file) {
            is ByteArray -> form.addFormDataPart(type, "content", RequestBody.create(null, file))

Why not to implement according to https://core.telegram.org/bots/api#inputfile?