I’m well aware this question seems like a possible duplicate (e.g., 1, 2, 3), but I couldn’t find a straight answer to my scenario anywhere.
The exact flow is as follows:
- The Bot receives a message with a photo from a user. It then extracts and stores the
file_id
of the highest-quality photo out of themessage.photo
array (the last array item). - The bot fires a
getFile(file_id)
request using the storedfile_id
, which returns a single link (NOT an array) that points to a low-quality file (slightly bigger than a thumbnail).
To summarize:
- Using the exact
file_id
withgetFile()
returns a link to a low-quality file. - Using the exact
file_id
withsendPhoto()
will send a full-size photo.
On the chance I’m missing something here, can anyone confirm that that’s expected behavior? Thanks.
3
Answers
file_id’s are different in the photo array. use file_id which has the biggest file_size and then you could get the high quality file by getFile method
Base on image resolution, "photo" array contains different number file_id. Use
ctx.message.photo.lenght - 1
to access the last file_id for best quality.the best quality in -1 index