5: Uploads

The image and file field types handle uploads end to end: storage, tokenised URLs and, for images, thumbnails.

5.1: The image field

cover:  field (type: 'image', title: 'Cover', list: false)
avatar: field (type: 'image', title: 'Avatar', list: false)

An image field stores two columns: the filename (cover) and a token (cover_token). On upload it writes the original and a scaled thumbnail, and renders the thumbnail in the record view linking to the full image. The file field is the same without the image processing.

5.2: Where files go

The app entrypoint declares the storage roots:

files:  dirname(__DIR__).'/data/uploads/files/',
images: dirname(__DIR__).'/data/uploads/images/',
thumbs: dirname(__DIR__).'/data/uploads/thumbs/',

Files are served back through a tokenised route, so URLs are not guessable from the row id. Keep data/uploads/ out of git.

5.3: Schema columns

When you hand-write the table (as the SQLite demo does), remember an image field is two columns:

cover TEXT, cover_token TEXT

The demo's seed.phlo creates exactly these columns alongside the relation columns.

We use essential cookies to make this site work. With your permission we also use analytics to improve the site.