KurimuzonAkuma/pyrogram

The file id contains an expired file reference

Closed this issue · 0 comments

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

app.download_media(message, file_name=filename)
some time it run error

pyrogram.errors.exceptions.bad_request_400.FileReferenceExpired: Telegram says: [400 FILE_REFERENCE_EXPIRED] - The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context (caused by "upload.GetFile")

It may be because the download time is too long or there is a flood waiting. Can you automatically re-read the message and try to download?

Steps to reproduce

app.download_media(message, file_name=filename) show The file id contains an expired file reference

Code example

app.download_media(message, file_name=filename)

Logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/client.py", line 1007, in get_file
    r = await session.invoke(
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 399, in invoke
    return await self.send(query, timeout=timeout)
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/session/session.py", line 367, in send
    RPCError.raise_it(result, type(data))
  File "/usr/local/lib/python3.8/dist-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.bad_request_400.FileReferenceExpired: Telegram says: [400 FILE_REFERENCE_EXPIRED] - The file id contains an expired file reference, you must obtain a valid one by fetching the message from the origin context (caused by "upload.GetFile")