Uploads And Processing
Upload behavior is split between route handlers, multipart reading, content resolution, scanner integration, persistence, and background processing.
Upload Flow
- Route handler checks feature flags, policy, CSRF when applicable, and rate limits.
- Multipart or URL upload is read to a temporary file.
- Content type is resolved from sniffed bytes, declared content type, filename extension, then
application/octet-stream. - MIME policy, filename length, blocked hashes, blocked MIME types, and quota are checked.
- Optional metadata stripping rewrites JPEG or PNG uploads.
- SHA-256 hash is computed.
- External scanners run.
- Blob row and file item row are created.
- Blob bytes are written if the object does not already exist.
- Scanner results are recorded.
- Active uploads return URLs; quarantined or rejected uploads return errors.
URL Upload
URL upload validates scheme, host, ports, redirects, timeouts, response size, and private IP behavior before reading the response.
Processing
src/processing.rs handles MIME sniffing, metadata JSON, metadata stripping helpers, image dimensions, and thumbnail derivatives.
Background jobs fill missing metadata and thumbnails for existing files when configured:
[processing]
metadata_extraction = true
thumbnails = true
Storage
src/storage.rs wraps object_store for local and S3-compatible backends. Blob paths are derived from sanitized hex hashes and optional S3 prefixes.
Tests
Upload-related changes should include focused tests for resolver behavior plus route-level tests when policies, forms, or API behavior changes.