T
T
TheCorpio2022-01-21 22:45:17
Python
TheCorpio, 2022-01-21 22:45:17

Python + aiogram why can't I download photos?

Good afternoon. I'm trying to make a bot. The problem is this. There is a code that, as soon as a message with a photo is sent, he must download it. It seems that I did it according to the manual from the off site, but I don’t understand what’s wrong. Registered a way completely I thought a problem in it. I tried with pathlib. Just nothing happens. Here is full code:src = f'D:/Python/test' + file_path

@dp.message_handler(content_types=['photo'])
async def send_photo(message: types.Message):
    file_id = message.photo[-1].file_id
    file = await bot.get_file(file_id)
    file_path = file.file_path
    src = pathlib.Path.cwd()
    await bot.download_file(file_path, src)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question