C&C Docs
Log in
Platform services

$file

An uploaded file is a row, _File/<id>, and its bytes live in an object store beside it. $file uploads, mints the URLs that show a file, and deletes it. Your own rows keep only the key: here each picture is a FileCard whose picture column holds a _File key.

An upload is always somebody's. Log in or create an account to upload pictures of your own.

Upload, show, delete

The controller can upload bytes it made; the browser hands $file.upload the <input type=file> itself. Either way the upload answers a key, and the page writes that key on a row of its own. The pictures are the template calling $file.thumbnail: the URLs it mints are signed and expire, so a copied link stops working after a while.

// In the controller: bytes in, a key out, the key on your own row.
async $sample() {
  const file = await $file.upload(bytes, { filename: 'sample.png' })
  await this.$data.create('FileCard', { label: file.name, picture: file._key })
}

// In the browser: hand it the <input type=file> itself.
async pick(input) {
  const file = await $file.upload(input)
  await this.$keep(file._key, file.name)
}

// In the template: minting a URL is synchronous.
<img :src="$file.thumbnail(card.picture, { width: 112 })" />
<a :href="$file.download(card.picture)">…</a>

// Deleting takes the row, the bytes and every thumbnail.
await $file.delete(card.picture)

Next: a drive, where folders of files are rows too.