I’m working with a Telegram bot and noticed something strange with file uploads. When users send document files like PDFs or text files, the API response includes the original filename in the response data. But when they upload images, the filename is completely missing from the response.
Document upload response (works fine):
{
"update_id": 987654321,
"message": {
"message_id": 25,
"from": {
"id": 1234567890,
"is_bot": false,
"first_name": "John",
"username": "john_doe"
},
"document": {
"file_name": "report.txt",
"mime_type": "text/plain",
"file_id": "BQACAgUAAxkBAAMoZvIvTyoUOQUwqs8JkQlUWyADDCMAArsQAAJklpFX9DE7pYrYYYk2BA",
"file_size": 45000
}
}
}
Image upload response (filename missing):
{
"update_id": 987654322,
"message": {
"message_id": 26,
"from": {
"id": 1234567890,
"is_bot": false,
"first_name": "John",
"username": "john_doe"
},
"photo": [
{
"file_id": "AgACAgUAAxkBAAMpZvI4PMcy02obaSa47F9dsjKuleIAAmvBMRtklpFX",
"width": 320,
"height": 240,
"file_size": 15000
}
]
}
}
How can I get the original image filename from the Telegram API response? I need it for proper file processing.