Search code examples
telegramtelegram-botpython-telegram-botpy-telegram-bot-api

How to send large files through Telegram Bot?


I've been working on a bot that would send users videos (mostly larger than 500mb). I've read the telegram bot api docs. There is a restriction of 50MB, with videos/animations/documents. In the recent changes, Telegram announced now bots can send files upto 2000 MB.

I'm using Python Telegram Bot wrapper. I've tried to send videos using both from direct url and from directory. But it fails and shows the file size limitation error. I also tried with get requests to Telegram Bot API. It failed.

There are many bots that are uploading files upto 2GB, So, my question is how to do it?


Solution

  • As pointed by @valijon in this answer you could also try to send files through InputStream, http url and cached file IDs. Also, I'd recommend you to take a look at Pyrogram:

    # Keep track of the progress while uploading
    def progress(current, total):
        print(f"{current * 100 / total:.1f}%")
    
    app.send_video("me", "video.mp4", progress=progress)