Media Module

Raw binary file storage — chunked upload, download sessions, temporary access grants, storage quota enforcement, and provider abstraction.

The Media module owns raw binary file storage. It provides chunked upload for large files, temporary download links (MediaAccessGrant), folder organization, and storage quota checks against Entitlements. Media is NOT Documents — it owns the binary. Document management consumes Media for storage while owning business semantics (versioning, approval, expiry).

Chunked Upload

Large files are uploaded in chunks via StartUploadSessionCommand (creates a MediaUploadSession) followed by repeated UploadChunkCommand calls. The session tracks total chunks, received chunks, and completion state. On final chunk, the file is assembled, hash-verified, and a MediaFile record is created. Upload sessions expire after 24 hours of inactivity.

Temporary Access Grants

MediaAccessGrant generates time-limited download URLs without exposing raw storage credentials. The DownloadsController validates the grant token, checks expiry, and streams the file. Grants can be single-use or multi-use with configurable TTL. This pattern separates authentication (who can generate a grant) from access (anyone with the token within TTL).

Storage Quotas

Upload requests check the tenant's Media.StorageQuotaGb feature gate in Entitlements before accepting a file. The quota check is performed in the command handler via IFeatureChecker — the Media module never reads Entitlements tables directly. Quota overages return a structured error that the frontend displays as a storage upgrade prompt.

Permissions

media.files.view/upload/delete | media.folders.create/update/delete | media.access.grant | media.admin | media.export