Backend: logo/watermark image upload endpoint #104

Closed
opened 2026-07-02 19:44:02 +02:00 by timothy · 2 comments
Owner

From the ChicoryTV plan audit (epic #59, 2026-07-02).

No image-upload path exists (zero IFormFile usage in the codebase). CreateChannel.Logo takes an ArtworkContentTypeModel(Path, ContentType) that assumes the file is already on disk; ArtworkController only serves artwork and generates text logos. The Channel Builder's image dropzone (#89) has nowhere to POST. #66 (format support) and #67 (unified logo/bug) both assume upload exists — neither scopes it.

Scope

  • POST /api/artwork/uploads (multipart) accepting an image, validating type/size, storing it as artwork usable for channel logo and watermark, returning {path, contentType} consumable by CreateChannel.Logo / channel update.
  • Note for #67: reconcile the DTO asymmetry — Logo is inline ArtworkContentTypeModel while watermark is a bare WatermarkId reference.
  • Regenerate OpenAPI + SPA types.

Hard-blocks #89 (channel image step). Related: #66 (accepted formats incl. WebP), #67 (one image drives logo + bug).
Effort: M.

From the ChicoryTV plan audit (epic #59, 2026-07-02). **No image-upload path exists** (zero `IFormFile` usage in the codebase). `CreateChannel.Logo` takes an `ArtworkContentTypeModel(Path, ContentType)` that assumes the file is already on disk; `ArtworkController` only serves artwork and generates text logos. The Channel Builder's image dropzone (#89) has nowhere to POST. #66 (format support) and #67 (unified logo/bug) both *assume* upload exists — neither scopes it. **Scope** - `POST /api/artwork/uploads` (multipart) accepting an image, validating type/size, storing it as artwork usable for channel logo and watermark, returning `{path, contentType}` consumable by `CreateChannel.Logo` / channel update. - Note for #67: reconcile the DTO asymmetry — `Logo` is inline `ArtworkContentTypeModel` while watermark is a bare `WatermarkId` reference. - Regenerate OpenAPI + SPA types. **Hard-blocks #89** (channel image step). Related: #66 (accepted formats incl. WebP), #67 (one image drives logo + bug). Effort: M.
timothy added the enhancementapi labels 2026-07-02 19:44:02 +02:00
timothy added a new dependency 2026-07-02 19:44:16 +02:00
Author
Owner

Picking this up. Recon findings on the salvaged WIP (31a4aaba):

  • Command/handler/DTO look structurally sound: validates png/jpeg/gif/webp, stores via IImageCache.SaveArtworkToCache, returns iptv/logos/{file} for logos / bare filename for watermarks — matching the Blazor ChannelEditor.razor upload path.
  • Controller is missing ControllerBase inheritance — will fix.
  • No tests in the WIP: adding controller tests (route/Name/mediator pass-through, validation → 422), handler tests, and the OpenApiErrorResponseContractTests 422 entry.
  • Size limit mirrors legacy: SystemEnvironment.MaximumUploadMb (default 10 MB, ETV_MAXIMUM_UPLOAD_MB).

Rebased onto current main (post-#115/#116); OpenAPI v1.json will be regenerated at the end.

Picking this up. Recon findings on the salvaged WIP (31a4aaba): - Command/handler/DTO look structurally sound: validates png/jpeg/gif/webp, stores via `IImageCache.SaveArtworkToCache`, returns `iptv/logos/{file}` for logos / bare filename for watermarks — matching the Blazor `ChannelEditor.razor` upload path. - Controller is missing `ControllerBase` inheritance — will fix. - No tests in the WIP: adding controller tests (route/Name/mediator pass-through, validation → 422), handler tests, and the `OpenApiErrorResponseContractTests` 422 entry. - Size limit mirrors legacy: `SystemEnvironment.MaximumUploadMb` (default 10 MB, `ETV_MAXIMUM_UPLOAD_MB`). Rebased onto current main (post-#115/#116); OpenAPI v1.json will be regenerated at the end.
Author
Owner

Closing summary (merged via PR #117, commit 3d086aab)

What was done: POST /api/artwork/uploads (multipart/form-data) for channel logo + watermark artwork. Validates content type (png/jpeg/gif/webp) and size (SystemEnvironment.MaximumUploadMb, default 10 MB); stores via IImageCache.SaveArtworkToCache (SHA1 content-addressed, identical dedup to the Blazor path); returns 201 { path, contentType } with path directly consumable as CreateChannel.Logo (iptv/logos/{file} for logos, bare cache filename for watermarks); Location header carries the servable URL incl. required ?contentType=. All failures are 422 ProblemDetails Validation failed.

Files changed: ErsatzTV.Application/Artworks/Commands/UploadArtwork{,Handler}.cs, ErsatzTV.Core/Api/Artwork/ArtworkUploadResponseModel.cs, ErsatzTV/Controllers/Api/ArtworkUploadController.cs, controller + handler tests, OpenApiErrorResponseContractTests 422 entry, regenerated v1.json.

Adversarial review: one MAJOR (DTO missing #nullable enable → spec documented nullable strings, breaking SPA typegen quality) — fixed pre-merge. Deferred minors: bare 413 above the Kestrel 30 MB transport limit (app-wide behavior, not endpoint-specific); logo Location points at the conditionally-authorized IPTV route (informational header only); content-type trusted from client header — parity with legacy, magic-byte sniffing tracked in #66.

Deferred/follow-ups: none new; #66 covers content sniffing/format work. SPA type regen not applicable (no web/ on main yet).

Docs: none needed — API surface is self-documented via OpenAPI; no operational behavior change.

Unblocks #89 (Channel Builder image step).

## Closing summary (merged via PR #117, commit 3d086aab) **What was done**: `POST /api/artwork/uploads` (multipart/form-data) for channel logo + watermark artwork. Validates content type (png/jpeg/gif/webp) and size (`SystemEnvironment.MaximumUploadMb`, default 10 MB); stores via `IImageCache.SaveArtworkToCache` (SHA1 content-addressed, identical dedup to the Blazor path); returns 201 `{ path, contentType }` with `path` directly consumable as `CreateChannel.Logo` (`iptv/logos/{file}` for logos, bare cache filename for watermarks); Location header carries the servable URL incl. required `?contentType=`. All failures are 422 ProblemDetails `Validation failed`. **Files changed**: `ErsatzTV.Application/Artworks/Commands/UploadArtwork{,Handler}.cs`, `ErsatzTV.Core/Api/Artwork/ArtworkUploadResponseModel.cs`, `ErsatzTV/Controllers/Api/ArtworkUploadController.cs`, controller + handler tests, `OpenApiErrorResponseContractTests` 422 entry, regenerated `v1.json`. **Adversarial review**: one MAJOR (DTO missing `#nullable enable` → spec documented nullable strings, breaking SPA typegen quality) — fixed pre-merge. Deferred minors: bare 413 above the Kestrel 30 MB transport limit (app-wide behavior, not endpoint-specific); logo Location points at the conditionally-authorized IPTV route (informational header only); content-type trusted from client header — parity with legacy, magic-byte sniffing tracked in #66. **Deferred/follow-ups**: none new; #66 covers content sniffing/format work. SPA type regen not applicable (no `web/` on main yet). **Docs**: none needed — API surface is self-documented via OpenAPI; no operational behavior change. Unblocks #89 (Channel Builder image step).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: timothy/ersatztv#104