feat(media): local-disk media storage, catalogue images and organization documents on disk (#18) #116
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!116
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/18-media-storage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Local-disk media storage behind a swappable
media.Blobsinterface (#18):api/internal/media+media/localfs(rootKWS_MEDIA_DIR; temp file, fsync, rename, dir fsync; keys are uuidv7, validated; files 0600).mediatable (one owner: park, product or category);organization_documents.content(bytea) dropped,blob_keyadded. The migration refuses to run iforganization_documentshas rows.Mediaoperations: admin list/upload/update/delete (admin_portal.administration.manage, platform scope,no-store) and public lists +GET /v1/media/{id}(max-age=3600, ETag,nosniff). JPEG/PNG/WebP sniffed, 5 MiB, 10 per owner.media.sweepworker job deletes unreferenced files older than 24 h (registered only when the dir is set).KWS_MEDIA_DIRunset = media disabled: uploads and organization document upload answer a fixed 503.Why
Org documents were
byteaas a stop-gap (ADR 0021) and the catalogue had no images. Production is one machine, so local disk is enough; the interface keeps S3-style backends possible later.Verification
make cover: 91.0% (minimum 80%);make lint0 issues;make contractok;go test -race -count=1 ./...ok; client generation ok.Rulings I made
media.NewKeybuilds uuidv7 by hand (no uuid module in go.mod; version/variant bits tested).FOR NO KEY UPDATE(still serialises the 10-limit; mutation-tested).rest.Uploadhelper, Dockerfile media dir, no Retry-After for orgs ErrDisabled, ADR notes.localfs.Put, optionalTmpPrunerinterface, lost-COMMIT-ack blob handling (rare 404 + Error log).Owner please check ([verify] in ADR 0025)
KWS_MEDIA_DIRis unset.Not verified
Real upload viewed through a running API; Docker image build independently; ENOSPC/power loss; docs/02 still names MinIO outside the Files row.
🤖 Generated with Claude Code