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.&MediaReuploadRequest
required
Parameters identifying the media message to re-upload.
MediaRetryResult
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
MediaRetryResult
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