Skip to content

Documentation

Storage

Store files in buckets, control access with policies, share them with signed URLs and resize images on request.

Buckets

A bucket is a folder at the top level of your project's storage. Create buckets on the Storage page, or in SQL. For each bucket you can set whether it is public, a maximum file size and the allowed MIME types.

  • Public buckets serve files to anyone who has the URL. Uploads still need a policy.
  • Private buckets need a signed URL or an authenticated request that a policy allows.

Upload and download

// uploadconst { error } = await vulcbase.storage.from("avatars").upload(`${user.id}/me.png`, file, {  contentType: "image/png",  upsert: true,}); // downloadconst { data: blob } = await vulcbase.storage.from("avatars").download(`${user.id}/me.png`); // list, move, removeawait vulcbase.storage.from("avatars").list(user.id);await vulcbase.storage.from("avatars").move("a.png", "b.png");await vulcbase.storage.from("avatars").remove(["b.png"]);

Policies

Files are rows in storage.objects, so access is plain Row Level Security. This lets each user manage the files in a folder named after their id:

create policy "users manage their folder" on storage.objects  for all to authenticated  using (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text)  with check (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);
Without a matching policy, an upload with the anon or user key is refused. The service_role key skips policies.

Public and signed URLs

// public bucketconst { data } = vulcbase.storage.from("avatars").getPublicUrl("ana/me.png"); // private bucket: link valid for 10 minutesconst { data: signed } = await vulcbase.storage.from("documents").createSignedUrl("contracts/q4.pdf", 600);

Image resizing

Ask for a resized version of an image with transform options. The original is not changed.

const { data } = vulcbase.storage.from("avatars").getPublicUrl("ana/me.png", {  transform: { width: 160, height: 160, resize: "cover", quality: 80 },});

Limits

File storage is counted per organization and depends on your plan: 1 GB on Free, 100 GB on Pro, 500 GB on Team. A maximum upload size can be set per bucket and for the whole project in the storage settings. See plan limits.