Skip to content

feat(resource-detail): add file size and mime type to document links#1691

Merged
rudivanhierden merged 3 commits into
openstad:mainfrom
SerdarAydemir:feature/document-metadata
Jul 14, 2026
Merged

feat(resource-detail): add file size and mime type to document links#1691
rudivanhierden merged 3 commits into
openstad:mainfrom
SerdarAydemir:feature/document-metadata

Conversation

@SerdarAydemir

Copy link
Copy Markdown
Contributor

What

Document download links now show the file size next to the type, e.g.
Title (PDF, 4,3 MB), with Dutch number notation. Builds on #1674 (Part 1).

After

Bijlage-met-metadata

The bottom document was uploaded after this change and shows the size;
the documents above it predate the change and gracefully fall back to
(PDF) — existing documents keep working unchanged.

Why

Relates to #1669 (Part 2). Part 1 added accessible humanized labels and the
file type. This part adds the file size, which WCAG 2.1 SC 2.4.4 calls for so
users know what they're downloading before they open it.

How — the size flows end-to-end

Tracing the upload chain, the size was being dropped at several points; this
PR fixes each:

  1. image-server (/document, /documents): the upload response now
    includes size (bytes) and mimeType, which multer already provides.
  2. admin document-uploader: forwards size/mimeType from the upload
    response to the form (previously only url/name).
  3. admin resource-form: the zod schema for documents now accepts
    size/mimeType — zod strips unknown keys on submit, so without this the
    size never reached the API.
  4. resource-detail widget: formatDocumentLabel takes the size and
    renders (PDF, 4,3 MB), with kB/MB formatting and a no-size fallback.

The documents field on the resource is a schemaless JSON column, so no
migration is needed.

Testing

  • Component tests cover the label formatting (MB/kB, Dutch comma, no-size
    fallback) — 11 cases.
  • Verified end-to-end locally: uploaded a PDF via the admin panel and
    confirmed size/mimeType are stored and rendered (see screenshot).

Notes

Add file size to document download labels end-to-end, e.g. 'Title (PDF, 4,3 MB)', with Dutch number notation. Existing documents without stored size keep showing 'Title (PDF)' as a fallback. The size flows through the full chain: the image-server upload endpoints now return size and mimeType, the admin document-uploader forwards them, the resource-form zod schema accepts them (it previously stripped unknown keys on submit), and the resource-detail widget renders them via formatDocumentLabel. Covered by component tests for the kB/MB formatting and the no-size fallback.

Closes openstad#1669 (Part 2)
@SerdarAydemir

Copy link
Copy Markdown
Contributor Author

Heads-up: the Docker build check is failing on denied: installation not allowed to Write organization package when pushing to ghcr.io. This looks like a registry-write permission issue for PRs from forks, not something in the diff — the Prettier and other checks pass. Let me know if there's anything I should change on my side.

@rudivanhierden rudivanhierden added this to the v2.7 milestone Jul 14, 2026
@rudivanhierden
rudivanhierden merged commit df4d086 into openstad:main Jul 14, 2026
3 checks passed
@cypress

cypress Bot commented Jul 14, 2026

Copy link
Copy Markdown

Openstad Headless    Run #1893

Run Properties:  status check passed Passed #1893  •  git commit df4d086277: feat(resource-detail): add file size and mime type to document links (#1691)
Project Openstad Headless
Branch Review main
Run status status check passed Passed #1893
Run duration 33m 19s
Commit git commit df4d086277: feat(resource-detail): add file size and mime type to document links (#1691)
Committer Serdar Aydemir
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 104
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants