Media Architecture
- R2 stores the binary file under a key the application generates.
- D1 stores metadata (content type, size, dimensions, alt text, folder) and the R2 key. Binaries are never stored in D1.
- Uploads are PNG, GIF, JPEG or WebP, verified by their bytes, up to 10 MB.
- Media is immutable: there is no edit-in-place endpoint. Create and delete only, plus editing of metadata such as alt text and folder.
Public delivery
Section titled “Public delivery”| Endpoint | Returns |
|---|---|
GET /api/v1/public/media/{id}/file |
The file. Cached for one year (immutable), and invalidated when the item is deleted |
GET /api/v1/public/media/{id} |
{ altText, contentType, width, height } |
GET /api/v1/public/media/folders/{slug} |
Items in a media folder |
Media has no draft or published state: once uploaded, any id is servable, the same trust model as any CDN asset URL. Form attachments are stored separately and are only downloadable through an authenticated admin route.
R2 has no built-in versioning or point-in-time recovery, unlike D1. See Backups.