KKiotaPay UI
Browse documentation

S3 File Viewer

An inline preview of one stored file: an image when it is one, a labelled link when it is not.

Installation

pnpm dlx shadcn@latest add https://kiotapay-ui-staging.staging.kiotapay.com/r/s3-file-viewer.json

Installs the component and lib/kiota-storage.tsx. Wire the adapter once — see Storage adapter.

Usage

import { S3FileViewer } from '@/components/custom/s3-file-viewer'

export function AvatarCell({ row }) {
  return <S3FileViewer url={row.original.photoKey} alt="Employee photo" className="size-10 rounded-full" />
}

Props

PropTypeDefaultDescription
urlstring | null—A storage key, or an http/data/blob URL.
altstring'file'Alt text for the image branch.
classNamestring—Applied to the wrapper.
adapterStorageAdapter—Overrides the provider for this instance.

Behaviour notes

Renders null for an empty value, so it can sit unguarded in a table column that is often blank.

URLs skip the round trip. A value that already starts with http:, https:, data: or blob: is used as-is — only opaque keys are sent to getFile.

Filenames drop their prefix. Keys are typically <timestamp>_<original name>; the display strips everything up to the first underscore, because otherwise every filename in a list begins with the same unreadable run of digits. The full name stays in the title attribute.

A failed resolve falls back to the raw value rather than blanking out, so a filename the user can still read survives an expired presign endpoint.

For anything bigger than a thumbnail, use View S3 Attachment — it opens a dialog with PDF, video and audio handling.