Storage

File storage with rules written in SQL

Upload images, videos and documents into public or private buckets. Serve public files by URL, protect private ones with signed URLs, and control access with policies on storage.objects.

const file = event.target.files[0]
const { data, error } = await stitchdb.storage
  .from('avatars')
  .upload(`${user.id}/avatar.png`, file, { upsert: true })

const { data: { publicUrl } } = stitchdb.storage.from('avatars').getPublicUrl(data.path)

// Private buckets: create a temporary link
const { data: signed } = await stitchdb.storage.from('invoices').createSignedUrl('2026/10.pdf', 60)

What you get

Buckets, URLs and policies

Public and private buckets

Public buckets serve files to anyone with the URL; private buckets require a policy or a signed URL.

Signed URLs

createSignedUrl(path, seconds) gives time-limited access to private files.

Policies

Access rules on storage.objects use the same auth.uid() you use for tables.

Uploads up to 50 MB per file on Free and 5 GB on Pro and Scale.

How it works

Get started with Storage

  1. Create a bucket

    In Studio → Storage, or admin.storage.createBucket('avatars', { public: true }).

  2. Upload

    stitchdb.storage.from('avatars').upload(path, file, { upsert: true })

  3. Serve

    getPublicUrl for public buckets, createSignedUrl for private ones.

SQL
create policy "Users upload their own avatar" on storage.objects
  for insert to authenticated
  with check (bucket_id = 'avatars' and owner_id = auth.uid()::text);

Start building on StitchDB today

Create your first project in under a minute.