Skip to main content

Module uploaded_file

Module uploaded_file 

Source
Expand description

Scratch storage for multi-step media uploads.

The editor uploads bytes first, then fills in title / alt / collection on a follow-up form, then the row commits to crate::media::Media. If the editor cancels or closes the tab mid-step, the scratch row is collected by the background sweep — no orphan media leaks into cms_media.

Existing single-step media_upload_submit keeps working unchanged; this primitive is the foundation for future drag-drop / multi-file UIs where bytes arrive faster than the editor can fill metadata.

Scratch objects live under the storage key <tenant>/scratch/<hash>-<filename> so the commit path can rename in place rather than copying bytes across volumes.

Structs§

UploadedFile

Constants§

STALE_THRESHOLD_HOURS
How long a scratch upload sticks around before the sweep collects it. Generous — editors sometimes step away mid-upload.

Functions§

create
Insert one scratch row.
delete
Delete one scratch row by id. Returns the number of rows removed (0 or 1). Filesystem cleanup is the caller’s responsibility — this only touches the DB row.
gc_stale
Drop every scratch row older than STALE_THRESHOLD_HOURS. Filesystem-side cleanup is the caller’s responsibility — the sweep returns the list of storage_keys the caller should unlink so the IO happens outside any held DB lock.
get
Look up a scratch row by id. Returns None when missing — callers should treat that as the editor cancelled / sweep collected.