S
S
S1ckret2021-03-26 14:53:06
Python
S1ckret, 2021-03-26 14:53:06

How to find the file_id of a photo in aiogram?

You are welcome. Help me learn how to get the file_id of a photo. None of the sites have proper instructions. Thanks in advance
In python

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2021-03-26
@S1ckret

None of the sites have proper instructions.
Not true, there are offs. docs - docs.aiogram.dev . But since I have not worked with this library and do not plan to, I do not want to read them for you.
It took exactly 2 minutes to google:
@dp.message_handler(content_types=['photo'])
async def scan_message(msg: types.Message):
    document_id = msg.photo[0].file_id
    file_info = await bot.get_file(document_id)
    print(f'file_id: {file_info.file_id}')
    print(f'file_path: {file_info.file_path}')
    print(f'file_size: {file_info.file_size}')
    print(f'file_unique_id: {file_info.file_unique_id}')

file_id: AgACAgIAAxkBAAIO2WBd12gIEuhnEzsUgfS_VguqIVMLAAK5sDEb0qrwSiETN9pic8VjZPdZoi4AAwEAAwIAA20AA3dRAAIeBA
file_path: photos/file_48.jpg
file_size: 12946
file_unique_id: AQADZPdZoi4AA3dRAAI

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question