@SashaN69
Школота

Ошибка «a bytes-like object is required, not '_io.BytesIO'»?

Доброго времени суток. Решил сделать чтобы бот сохранял фото которые, отправил юзер, но тут столкнулся с ошибкой a bytes-like object is required, not '_io.BytesIO'.Возможно кто-то знает как можно исправить?
@dp.message_handler(content_types=['photo'])
async def handle_docs_photo(message):
    try:
        file_info =  await bot.get_file(message.photo[0].file_id)
        downloaded_file =  await bot.download_file(file_info.file_path)

        src = 'C:/Users/Sasha/Desktop/Bot/images/' + message.photo[0].file_id
        with open(src, 'wb') as new_file:
            new_file.write(downloaded_file)
        await bot.send_message(message.from_user.id, "Фото добавлено")

    except Exception as e:
        await bot.send_message(message.from_user.id, e)
  • Вопрос задан
  • 2719 просмотров
Решения вопроса 1
@AWEme
Retard Soft Inc.
new_file.write(downloaded_file) -> new_file.write(downloaded_file.getvalue())
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы