GRI-1874: media upload and storage (signage #14) #95

Merged
vivy merged 1 commit from feature/GRI-1874-signage-media-upload-storage into dev 2026-11-10 00:19:35 +00:00
Member

What

Closes signage #14: media upload and storage.

  • GET /api/v1/media — lists every media item, oldest first.
  • POST /api/v1/media — uploads an image or video (multipart, file
    field). The bytes are hashed with sha256 and written once to the media
    directory, keyed by that hash; the catalog gets a new row regardless, so
    two uploads of the same bytes are two list entries, matching the comment
    on MediaId in crates/shared/src/ids.rs.
  • POST /api/v1/media/url — adds a URL-backed item: a name and an
    absolute http/https address, no upload.
  • DELETE /api/v1/media/{id} — removes the catalog entry; 404 when it
    does not exist, 409 media_in_use while a playlist item still
    references it (the existing playlist_items.media_id foreign key), and
    removes the file from disk only once no other entry still carries the
    same sha256.

All four sit behind CurrentUser, the same session extractor #10 added.

PDF upload is classified and then refused with unsupported_media_type:
the page converter is Voidgazer's GRI-1868 (#15a), and wiring it in is
signage #15b, after both land. handlers::pdf_not_yet_supported is the
call site.

Migration

0002_media_url_and_optional_checksum.sql:

  • sha256 and size_bytes become nullable, and gain a url column — a
    URL-backed entry has no bytes.
  • kind accepts 'url' alongside 'image'/'document'/'video'.
  • Drops the UNIQUE constraint on sha256. That constraint was my own
    mistake in the #9b schema: it contradicted the design ids.rs already
    documented (two uploads of the same bytes remain two catalog entries).
    No down-migration, per this project's stated policy
    (plan/server/persistence.md, "Forward only in normal operation").

Test plan

  • cargo test -p server --all-targets --locked against a real
    Postgres (SIGNAGE_TEST_DATABASE_URL) — 74 unit + 10 + 5 + 3 + 15
    integration tests, all passing. New: media_integration.rs (15
    tests covering upload, URL add, list, delete, auth, validation and
    the dedup behaviour above) plus unit tests for classification and
    URL validation in media/handlers.rs.
  • cargo clippy -p server --all-targets -- -D warnings clean.
  • cargo fmt --check clean.
  • ./scripts/local-gates.sh --rust-only — every gate passed.
  • cargo deny check — bans/licenses/sources ok. The
    advisories failures it reports (paste, proc-macro-error,
    glib) are pre-existing on dev, in the client crate's
    GTK/GStreamer tree, unrelated to this change, and non-blocking per
    ADR 0008.
## What Closes signage #14: media upload and storage. - `GET /api/v1/media` — lists every media item, oldest first. - `POST /api/v1/media` — uploads an image or video (multipart, `file` field). The bytes are hashed with sha256 and written once to the media directory, keyed by that hash; the catalog gets a new row regardless, so two uploads of the same bytes are two list entries, matching the comment on `MediaId` in `crates/shared/src/ids.rs`. - `POST /api/v1/media/url` — adds a URL-backed item: a name and an absolute `http`/`https` address, no upload. - `DELETE /api/v1/media/{id}` — removes the catalog entry; `404` when it does not exist, `409 media_in_use` while a playlist item still references it (the existing `playlist_items.media_id` foreign key), and removes the file from disk only once no other entry still carries the same `sha256`. All four sit behind `CurrentUser`, the same session extractor `#10` added. PDF upload is classified and then refused with `unsupported_media_type`: the page converter is Voidgazer's GRI-1868 (#15a), and wiring it in is signage #15b, after both land. `handlers::pdf_not_yet_supported` is the call site. ## Migration `0002_media_url_and_optional_checksum.sql`: - `sha256` and `size_bytes` become nullable, and gain a `url` column — a URL-backed entry has no bytes. - `kind` accepts `'url'` alongside `'image'`/`'document'`/`'video'`. - Drops the `UNIQUE` constraint on `sha256`. That constraint was my own mistake in the #9b schema: it contradicted the design `ids.rs` already documented (two uploads of the same bytes remain two catalog entries). No down-migration, per this project's stated policy (`plan/server/persistence.md`, "Forward only in normal operation"). ## Test plan - [x] `cargo test -p server --all-targets --locked` against a real Postgres (`SIGNAGE_TEST_DATABASE_URL`) — 74 unit + 10 + 5 + 3 + 15 integration tests, all passing. New: `media_integration.rs` (15 tests covering upload, URL add, list, delete, auth, validation and the dedup behaviour above) plus unit tests for classification and URL validation in `media/handlers.rs`. - [x] `cargo clippy -p server --all-targets -- -D warnings` clean. - [x] `cargo fmt --check` clean. - [x] `./scripts/local-gates.sh --rust-only` — every gate passed. - [x] `cargo deny check` — `bans`/`licenses`/`sources` ok. The `advisories` failures it reports (`paste`, `proc-macro-error`, `glib`) are pre-existing on `dev`, in the client crate's GTK/GStreamer tree, unrelated to this change, and non-blocking per ADR 0008.
GRI-1874: media upload and storage (signage #14)
Some checks failed
CI / the pre-push hook (pull_request) Successful in 6s
CI / cargo fmt (pull_request) Successful in 12s
CI / cargo deny (pull_request) Successful in 2m25s
CI / cargo deny advisories (pull_request) Failing after 1m59s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 10m19s
CI / cargo test (pull_request) Successful in 11m2s
CI / frontend-web (pull_request) Successful in 10m30s
CI / CI (pull_request) Successful in 11s
CI / Notify gate failed (pull_request) Has been skipped
4f4fe7ef3a
Images and videos upload with a sha256, stored once on disk by content
hash; web page URLs are added with no upload. Both list through
GET /media, behind the session extractor from #10.

PDF upload is refused with a clear error for now: the page converter is
GRI-1868 (#15a), and wiring it in is #15b.

Also drops the UNIQUE constraint on media.sha256, which contradicted the
comment on MediaId in shared::ids (two uploads of the same bytes are two
catalog entries; only the file on disk is deduplicated) -- a mistake in
my own earlier schema from #9b.
vivy merged commit 0eb1b00c9a into dev 2026-11-10 00:19:35 +00:00
vivy deleted branch feature/GRI-1874-signage-media-upload-storage 2026-11-10 00:19:35 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!95
No description provided.