You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pyrogram的download_media方法无法下载图片问题求助

Pyrogram的download_media方法无法下载图片问题求助

大家好,我最近在用Pyrogram写一个从Telegram消息里下载图片的简单函数,但遇到了棘手的问题:download_media方法完全下载不了图片,返回的file_path一直是None。

我能确认收到的message对象以及它的photo属性是包含有效数据的——打印出来的照片详情(比如文件ID、尺寸、大小这些)都正常,但下载操作就是没效果。我试过分别把message、m_photo还有file_id传给download_media,结果都没用。

下面是我的代码:

async def download_photo(message):
    m_photo = message.photo
    file_id = m_photo.file_id
    file_unique_id = m_photo.file_unique_id
    width = m_photo.width
    height = m_photo.height
    file_size = m_photo.file_size
    date = m_photo.date

    print(m_photo)
    print(f"Photo details - File ID: {file_id}, File Unique ID: {file_unique_id}, Width: {width}, Height: {height}, File Size: {file_size}, Date: {date}")

    file_path = await app.download_media(m_photo, file_name=f'{message.chat.id}_{file_unique_id}.jpg')
    return file_path

asyncio.run(download_photo(message))

有没有大佬能帮我看看问题出在哪呀?

备注:内容来源于stack exchange,提问作者abdus_salam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 09:38:03