简体   繁体   中英

How to upload file using multipart/form-data through python for telegram bot

I am making a simple telegram bot in python through google colab and want to upload voice note through sendVoice method and want Telegram clients to display the file as a playable voice message. for that i have found from Telegram bot API manual that i must use multipart/form-data to upload audio to bot. What is this multipart/form-data and how can i upload and use it through sendVoice method.

Thank you.

It is possible to send a file in the following manner via telebot and you don't need to worry about form-data.

    f = open('file_path', 'rb')
    bot.send_audio(chat_id, f)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM