File and Document Assets

File fields hold downloadable documents — PDFs, spreadsheets, presentations, and other documents your visitors need to access. Editors upload the file through the SleekCMS UI; the CMS stores it on the files CDN and exposes a stable URL, display name, size, MIME type, and extension.

This page covers what file fields store, the supported types and size limits, and how to render file links in templates and from the content API.


How File Fields Work

A file field on a content model accepts a single uploaded document. The editor's file picker uploads to SleekCMS storage and stores the resolved metadata on the content record. The original file is served as-is — no transformation, no compression. Documents are kept verbatim.

Do not write file field values by hand. The url and name are issued by the upload service. Hand-crafting them or pointing to external URLs is not supported in this field type — for external links, use a link field instead.


The File Object

A file field value resolves to an object with this shape:

{
  "name": "annual-report-2026.pdf",
  "url": "https://files.sleekcms.com/...",
  "size": 1843211,
  "type": "application/pdf",
  "ext": "pdf"
}
Property Description
name Display name of the uploaded file. Use this in download links.
url Download URL on the SleekCMS files CDN.
size File size in bytes.
type MIME type (e.g., application/pdf).
ext File extension without the leading dot (e.g., pdf).

Supported File Types

File fields accept documents in the following formats:

  • PDF (.pdf)
  • Spreadsheets (.csv, .tsv, .xls, .xlsx)
  • Word documents (.doc, .docx)
  • Presentations (.ppt, .pptx)
  • Plain text (.txt)

The maximum file size is 10 MB per upload. Anything larger needs a different hosting approach — for video, use a video field; for large archives or media, host externally and reference with a link field.


Rendering File Links in Templates

Use item.<field>.url as the link target and item.<field>.name as the display text. Add the download attribute if you want the browser to download the file rather than open it inline.

<% if (item.brochure) { %>
  <a href="<%= item.brochure.url %>" download>
    <%= item.brochure.name %>
  </a>
<% } %>

For a richer download card with size and type:

<% if (item.report) { %>
  <a href="<%= item.report.url %>" download class="file-link">
    <span class="file-name"><%= item.report.name %></span>
    <span class="file-meta">
      <%= item.report.ext.toUpperCase() %> · <%= Math.round(item.report.size / 1024) %> KB
    </span>
  </a>
<% } %>

Files via the Content API

When fetching content through the API, file fields return the same object shape stored on the record:

const page = client.getPage('/resources/whitepaper');
// page.document → {
//   name: 'whitepaper.pdf',
//   url: 'https://files.sleekcms.com/...',
//   size: 2018342,
//   type: 'application/pdf',
//   ext: 'pdf'
// }

Your frontend renders the link with document.url and document.name:

<a href={page.document.url} download>{page.document.name}</a>

What's Next