feat(web): file card and inline text preview on the public file page - #949
Conversation
Non-media files on /f/<workspace>/<key> and /g/:id/:item now show a file card (name, type, size, download link) via MediaFallback instead of a generic 'Preview unavailable' message. Small text/markdown/csv/json files (<=256 KiB) additionally get a server-rendered inline preview: the /f/ route fetches the object body SSR from storage with a 5s timeout, decodes it as UTF-8, and renders it as an escaped, scrollable <pre> block. Any fetch failure, timeout, non-2xx response, or oversized body falls back to the file card. Refs #946
🦋 Changeset detectedLatest commit: 828db72 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (2)
🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
On the public file page (
/f/<workspace>/<key>), non-media files no longer show a generic "Preview unavailable" fallback.MediaStage'skind === "file"branch now shows the file's identity — title = filename, body =<TYPE> · <size>, link = the download URL — via the existingMediaFallbackcomponent (no restyle). The gallery item page (/g/:id/:item) gets the same card via the same new props.text/plain,text/markdown,text/csv, orapplication/jsonand whose size is at most 256 KiB get an inline, server-rendered preview. The/f/route fetches the object body SSR from storage (server-to-server, no CORS concern) with a 5s timeout, decodes it as UTF-8, and renders it as an Astro-escaped, scrollable<pre>block (noset:html). Markdown is shown as source, never rendered. Any fetch failure, timeout, non-2xx response, or oversized body falls back to the file card. A small info line (type, size, download link) sits below the preview.Commands run
pnpm --filter @uploads/web astro syncpnpm --filter @uploads/web typecheck— 0 errorspnpm test(root) — all passingpnpm format:checkRefs #946