I’m experiencing inconsistent behavior when uploading files through the Telegram bot API. For instance, when I upload a text file, such as ‘example.txt’, the filename appears in the event. Here’s the JSON response I receive upon uploading a text file:
{'update_id': 154781156, 'message': {'message_id': 40, 'from': {'id': 6718326872, 'is_bot': False, 'first_name': 'Shantanu', 'last_name': 'Oak', 'username': 'soak', 'language_code': 'en'}, 'chat': {'id': 6718326872, 'first_name': 'Shantanu', 'last_name': 'Oak', 'username': 'soak', 'type': 'private'}, 'date': 1727147855, 'document': {'file_name': 'example.txt', 'mime_type': 'text/plain', 'file_id': 'FILE_ID_1', 'file_unique_id': 'UNIQUE_ID_1', 'file_size': 325405}}}
However, when I upload an image file, such as a jpg, the filename is missing from the response:
{'update_id': 154781157, 'message': {'message_id': 41, 'from': {'id': 6718326872, 'is_bot': False, 'first_name': 'Shantanu', 'last_name': 'Oak', 'username': 'soak', 'language_code': 'en'}, 'chat': {'id': 6718326872, 'first_name': 'Shantanu', 'last_name': 'Oak', 'username': 'soak', 'type': 'private'}, 'date': 1727150140, 'photo': [{'file_id': 'FILE_ID_2', 'file_unique_id': 'UNIQUE_ID_2', 'file_size': 829, 'width': 90, 'height': 50}, ...]}}
I need to retrieve the name of the image file in order to handle it properly, similar to how I receive the text file’s name.