MediaReupload struct provides a method to request the server to re-upload media when the original CDN URL has expired. This is essential for long-running bots that need to download media from older messages.
Access
Access media reupload operations through the client:Methods
request
Request the server to re-upload media for a message with an expired URL.Parameters identifying the media message to re-upload.
The result of the reupload request. On success, contains a new
direct_path for downloading.Protocol flow
- The client encrypts a
ServerErrorReceiptprotobuf using an HKDF-derived key from the media key - A
<receipt type="server-error">stanza is sent with the encrypted payload and<rmr>metadata - The client waits up to 30 seconds for a
<notification type="mediaretry">response - The response is decrypted and the new
directPathis extracted
Types
MediaReuploadRequest
| Field | Type | Description |
|---|---|---|
msg_id | &str | The message ID containing the media |
chat_jid | &Jid | The chat JID where the message was received |
media_key | &[u8] | Raw media key bytes (32 bytes, from the message’s mediaKey field) |
is_from_me | bool | Whether the message was sent by you |
participant | Option<&Jid> | For group/broadcast messages, the participant JID who sent the message |
MediaRetryResult
| Variant | Description |
|---|---|
Success | Server re-uploaded the media. Contains the new direct_path for downloading. |
GeneralError | Server returned a general error. |
NotFound | Media is no longer available on the server. |
DecryptionError | Failed to decrypt the server response. |
Error handling
The method returnsResult<MediaRetryResult>. The MediaRetryResult enum itself distinguishes between server-side success and failure. Additional errors can occur for:
- Newsletter messages — Media reupload is not supported for newsletter messages
- Timeout — The server did not respond within 30 seconds
- Encryption failure — Failed to encrypt the retry request
- Not logged in — Cannot determine own JID
Media reupload requests have a 30-second timeout. If the server does not respond in time, the request fails with a timeout error.
See also
- Media handling guide - Upload and download media
- Upload API - Upload media files
- Download API - Download media files