Expand description
Media repository for attachments. Blobs are opaque bytes: in E2E rooms
clients upload AES-CTR ciphertext (Matrix encrypted attachments), so the
server stores ciphertext only. They follow the ciphertext-pump rule: kept
for a TTL (see purge_expired) and then deleted. Plaintext uploads for
public channels use the same table and the same TTL for now; a separate
persistent public-media store is a named seam, not built.
Structs§
- Blob
- A fetched blob.
Enums§
- Part
- What the second part of a federation media answer holds.
Constants§
- MAX_
UPLOAD_ BYTES - Default largest accepted upload (and largest remote file fetched). Env:
M4A_MEDIA_MAX_BYTES.
Functions§
- create_
media_ schema - DDL (own table, outside the event tables).
- create_
pending - Reserves a media id for a later
PUT(POST /media/v1/create). - federation_
enabled - Is media federation (serving peers, fetching remote media) on? Cargo feature
media-federation(default) andM4A_MEDIA_FEDERATIONnotoff. - get
- Fetches a blob.
- get_
remote - A cached copy of another server’s file, if still fresh.
- is_
pending - Is a reservation open (the id was handed out and not yet filled)?
- max_
bytes - Largest upload / remote file in bytes (
M4A_MEDIA_MAX_BYTES). - multipart_
body multipart/mixedanswer of the federation media endpoints: a JSON part{}, then the file.- parse_
multipart - Parses a
multipart/mixedfederation media answer (JSON part, then data orLocation). - purge_
expired - Deletes blobs older than
ttl_ms. Returns how many. - put
- Stores a blob and returns its media id (24 url-safe chars).
- put_
remote - Caches another server’s file; drops expired copies, then the oldest while over the cap.
- put_
reserved - Fills a reserved id.
Ok(false): not reserved by this user (or expired);Err(Constraint)if filled already. - remote_
cache_ cap - Cap on all cached remote bytes (
M4A_MEDIA_REMOTE_CACHE_BYTES, default 512 MiB); oldest go first. - remote_
ttl_ ms - How long a cached remote file is kept, ms (
M4A_MEDIA_REMOTE_TTL_SECS, default 7 days). - thumbnail
- A thumbnail of an image, or
Nonewhen it is not a decodable image (ciphertext, other files) or the feature is off; callers then serve the original. Never enlarges.