Media Architecture
- R2 stores the binary file.
- D1 stores metadata (content type, size, dimensions, alt text) and the R2 object key. Binaries are never stored in D1.
- Uploads are limited to PNG, GIF, JPEG and WebP, verified by the file’s bytes.
- Public files are served by the API at
GET /api/v1/public/media/{id}/file, edge cached and invalidated on delete. Metadata is atGET /api/v1/public/media/{id}.
R2 has no built-in versioning or point-in-time recovery, unlike D1. Plan media backups separately.