Skip to main content

CnFilePreview

An in-page preview of a data file the Nextcloud Viewer does not show. A CSV or TSV renders as a table of its first 100 rows with the first row as header, JSON as a read-only formatted view, and XML or plain text as text. It fetches at most the first megabyte (Range: bytes=0-1048575), offers Download and Open in Files, and renders every cell as text, never as HTML. A file that cannot be read as a table (for example a CSV with unbalanced quotes) shows its raw text with a sentence saying so.

You rarely mount it yourself: CnFilesTab, CnFilesCard, CnFilesWidget and CnRelatedFiles open it through useFileOpener when the Viewer cannot show the type.

<CnFilePreview
v-if="file"
:file="{ name: 'Afvalinzameling 2025.csv', accessUrl: '/s/abc/download', id: 12, size: 3200000 }"
@close="file = null" />

The file needs a content URL (accessUrl, downloadUrl or url, validated by safeHref). id enables Open in Files; size lets the row count say "about N rows" for a long file.

Props​

PropDefaultDescription
filerequiredThe file row.
maxRows (max-rows)100Rows shown for a CSV or TSV, the header excluded.
maxBytes (max-bytes)1048576Bytes fetched at most.
dialogtrueWrap the preview in a dialog; false embeds it.

OpenRegister reliance​

medium: this component relies on OpenRegister for part of what it does. 0 direct references, 6 files reached through imports.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
fileunion✓—The file row: name, a content URL (accessUrl, downloadUrl or url), optionally type (mime), size and id (for Open in Files).
maxRowsnumber100Rows shown for a CSV or TSV, the header excluded.
maxBytesnumber1048576Bytes fetched at most.
dialogbooleantrueWrap the preview in a dialog. Pass false to embed it.

Events​

NamePayloadDescription
close—Emitted when the dialog is closed.