4

I'm working on a telegram bot and I need to download photo, audio, video sent by user to the bot. Using the only path returned by the get file method I only get a thumbnail. In fact the only result of the get file method contains a really tiny value for the file size. I can't figure out where the problem is. The photos are normally sent by message as photo (not as file).

Seyfi
  • 1,832
  • 1
  • 20
  • 35
ela
  • 104
  • 1
  • 10
  • Possible duplicate of [How to get photo in real size (not thumb) from telegram?](http://stackoverflow.com/questions/38106191/how-to-get-photo-in-real-size-not-thumb-from-telegram) – Maak Aug 20 '16 at 11:02

1 Answers1

8

first you should download the photo with this api to your bot

https://api.telegram.org/bot<token>/getfile?file_id={the file_id of the photo you want to download}

then it returns you a response of a File which has an attribute named file_path

then using the file_path you can download the photo full size using this

https://api.telegram.org/file/bot<token>/<file_path>

all of this is based on official documentation found here . Telegram API Doc

Masoud Haghbin
  • 863
  • 7
  • 13
  • 2
    This method still returns me a "thumbnail" version of an image – Eli Davis Mar 27 '19 at 23:57
  • I faced with same issue, Telegram resizing sent gifs max width/heigh to 320. FileSize from thumb and "original" the same, but width/height are different... Did you solve it, @EliDavis? – Nigrimmist Jun 07 '20 at 22:22
  • 3
    oh yeah! there's actually an array you select from, all with varying resolutions. When you receive a message update that's a photo, you actually receive an array of photo sizes. Pick the biggest one from that array and use it's specific file ID – Eli Davis Jun 08 '20 at 03:55
  • 1
    The hash has a SLIGHT change in it. I've been thinking they were the same for HOURS and always picked [0]. Thanks! – Fusseldieb Nov 26 '21 at 01:39