Functions

copy-object

fn (request: CopyObjectRequest): Map
fn (request: CopyObjectRequest, opts: Map): Map

Copy an object within or between buckets.

Example

::storage ::supabase::storage

::storage/copy-object(::storage/CopyObjectRequest({
  bucket_id: "avatars",
  source_key: "users/alice.jpg",
  destination_key: "backup/alice.jpg"
}))

create-bucket

fn (request: CreateBucketRequest): Map
fn (request: CreateBucketRequest, opts: Map): Map

Create a new storage bucket. Set public: true for publicly accessible files.

Example

::storage ::supabase::storage

::storage/create-bucket(::storage/CreateBucketRequest({
  name: "avatars",
  public: true,
  file_size_limit: 5242880,
  allowed_mime_types: ["image/png", "image/jpeg"]
}))

create-signed-upload-url

fn (bucket: Str, path: Str, expires-in: Int): SignedUploadUrlResponse
fn (bucket: Str, path: Str, expires-in: Int, opts: Map): SignedUploadUrlResponse

Create a signed URL for uploading an object without further authentication.

Example

::storage ::supabase::storage

target ::storage/create-signed-upload-url("documents", "reports/q3.pdf", 3600)
target.url
target.token

create-signed-upload-url-as

fn (bucket: Str, path: Str, expires-in: Int, access-token: Str): SignedUploadUrlResponse
fn (bucket: Str, path: Str, expires-in: Int, access-token: Str, opts: Map): SignedUploadUrlResponse

Like create-signed-upload-url, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
target ::storage/create-signed-upload-url-as("documents", "reports/q3.pdf", 3600, token)
target.url

create-signed-url

fn (bucket: Str, path: Str, expires-in: Int): SignedUrlResponse
fn (bucket: Str, path: Str, expires-in: Int, opts: Map): SignedUrlResponse

Create a signed URL for temporary access to a private object. expires-in is the validity in seconds.

Example

::storage ::supabase::storage

result ::storage/create-signed-url("documents", "reports/q1.pdf", 3600)
result.signedURL  // => "/storage/v1/object/sign/documents/reports/q1.pdf?token=..."

create-signed-url-as

fn (bucket: Str, path: Str, expires-in: Int, access-token: Str): SignedUrlResponse
fn (bucket: Str, path: Str, expires-in: Int, access-token: Str, opts: Map): SignedUrlResponse

Like create-signed-url, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
result ::storage/create-signed-url-as("documents", "reports/q1.pdf", 3600, token)
result.signedURL

create-signed-url-service

fn (bucket: Str, path: Str, expires-in: Int): SignedUrlResponse
fn (bucket: Str, path: Str, expires-in: Int, opts: Map): SignedUrlResponse

Like create-signed-url, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

result ::storage/create-signed-url-service("documents", "reports/q1.pdf", 3600)
result.signedURL

create-signed-urls

fn (bucket: Str, paths: Vec<Str>, expires-in: Int): Vec<Map>
fn (bucket: Str, paths: Vec<Str>, expires-in: Int, opts: Map): Vec<Map>

Create signed URLs for multiple objects in a bucket at once.

Example

::storage ::supabase::storage

urls ::storage/create-signed-urls("documents", ["reports/q1.pdf", "reports/q2.pdf"], 3600)
map(urls, %.signedURL)

delete-bucket

fn (bucket-id: Str): Map
fn (bucket-id: Str, opts: Map): Map

Delete a bucket. The bucket must be empty first (use empty-bucket).

Example

::storage ::supabase::storage

::storage/empty-bucket("avatars")
::storage/delete-bucket("avatars")

delete-object

fn (bucket: Str, path: Str): Any
fn (bucket: Str, path: Str, opts: Map): Any

Delete a single object from a bucket.

Example

::storage ::supabase::storage

::storage/delete-object("avatars", "users/alice.jpg")

delete-object-as

fn (bucket: Str, path: Str, access-token: Str): Any
fn (bucket: Str, path: Str, access-token: Str, opts: Map): Any

Like delete-object, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
::storage/delete-object-as("avatars", "users/alice.jpg", token)

delete-object-service

fn (bucket: Str, path: Str): Any
fn (bucket: Str, path: Str, opts: Map): Any

Like delete-object, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

::storage/delete-object-service("avatars", "users/alice.jpg")

delete-objects

fn (bucket: Str, prefixes: Vec<Str>): Any
fn (bucket: Str, prefixes: Vec<Str>, opts: Map): Any

Delete multiple objects from a bucket.

Example

::storage ::supabase::storage

::storage/delete-objects("avatars", ["old/file1.jpg", "old/file2.jpg"])

delete-objects-service

fn (bucket: Str, prefixes: Vec<Str>): Any
fn (bucket: Str, prefixes: Vec<Str>, opts: Map): Any

Like delete-objects, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

::storage/delete-objects-service("avatars", ["old/file1.jpg", "old/file2.jpg"])

download

fn (bucket: Str, path: Str): Any
fn (bucket: Str, path: Str, opts: Map): Any

Download a file from a private bucket. Returns the file content.

Example

::storage ::supabase::storage

content ::storage/download("documents", "reports/q1.pdf")

download-as

fn (bucket: Str, path: Str, access-token: Str): Any
fn (bucket: Str, path: Str, access-token: Str, opts: Map): Any

Like download, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
content ::storage/download-as("documents", "reports/q1.pdf", token)

download-service

fn (bucket: Str, path: Str): Any
fn (bucket: Str, path: Str, opts: Map): Any

Like download, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

content ::storage/download-service("documents", "reports/q1.pdf")

empty-bucket

fn (bucket-id: Str): Map
fn (bucket-id: Str, opts: Map): Map

Remove all objects from a bucket without deleting the bucket itself.

Example

::storage ::supabase::storage

::storage/empty-bucket("avatars")

get-bucket

fn (bucket-id: Str): StorageBucket
fn (bucket-id: Str, opts: Map): StorageBucket

Get a bucket by ID.

Example

::storage ::supabase::storage

bucket ::storage/get-bucket("avatars")
bucket.public

get-object-info

fn (bucket: Str, path: Str): Map
fn (bucket: Str, path: Str, opts: Map): Map

Get metadata about an object (size, MIME type, cache control, etc.).

Example

::storage ::supabase::storage

info ::storage/get-object-info("documents", "reports/q1.pdf")

get-object-info-as

fn (bucket: Str, path: Str, access-token: Str): Map
fn (bucket: Str, path: Str, access-token: Str, opts: Map): Map

Like get-object-info, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
info ::storage/get-object-info-as("documents", "reports/q1.pdf", token)

get-public-url

fn (bucket: Str, path: Str): Str
fn (bucket: Str, path: Str, opts: Map): Str

Build the public URL for an object in a public bucket. This is a pure string operation -- no API call.

Example

::storage ::supabase::storage

url ::storage/get-public-url("avatars", "users/alice.jpg")
// => "https://xxxx.supabase.co/storage/v1/object/public/avatars/users/alice.jpg"

list-buckets

fn (): Vec<StorageBucket>
fn (opts: Map): Vec<StorageBucket>

List all storage buckets.

Example

::storage ::supabase::storage

buckets ::storage/list-buckets()
// => [{id: "avatars", name: "avatars", public: true, ...}, ...]

list-objects

fn (request: ListObjectsRequest): Vec<StorageObject>
fn (request: ListObjectsRequest, opts: Map): Vec<StorageObject>

List objects in a bucket. Filter by prefix (folder path), search (filename pattern). sort_by is {column: "name", order: "asc"}.

Example

::storage ::supabase::storage

objects ::storage/list-objects(::storage/ListObjectsRequest({
  bucket: "avatars",
  prefix: "users/",
  limit: 100
}))
// => [{name: "alice.jpg", id: "...", metadata: {...}}, ...]

list-objects-as

fn (request: ListObjectsRequest, access-token: Str): Vec<StorageObject>
fn (request: ListObjectsRequest, access-token: Str, opts: Map): Vec<StorageObject>

Like list-objects, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
objects ::storage/list-objects-as(::storage/ListObjectsRequest({bucket: "avatars", prefix: "users/", limit: 100}), token)
map(objects, %.name)

list-objects-service

fn (request: ListObjectsRequest): Vec<StorageObject>
fn (request: ListObjectsRequest, opts: Map): Vec<StorageObject>

Like list-objects, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

objects ::storage/list-objects-service(::storage/ListObjectsRequest({bucket: "avatars", prefix: "users/", limit: 100}))
map(objects, %.name)

move-object

fn (request: MoveObjectRequest): Map
fn (request: MoveObjectRequest, opts: Map): Map

Move an object within or between buckets.

Example

::storage ::supabase::storage

::storage/move-object(::storage/MoveObjectRequest({
  bucket_id: "avatars",
  source_key: "tmp/alice.jpg",
  destination_key: "users/alice.jpg"
}))

// To another bucket
::storage/move-object(::storage/MoveObjectRequest({
  bucket_id: "avatars",
  source_key: "users/alice.jpg",
  destination_key: "alice.jpg",
  destination_bucket: "archive"
}))

update-bucket

fn (request: UpdateBucketRequest): Map
fn (request: UpdateBucketRequest, opts: Map): Map

Update a bucket's settings.

Example

::storage ::supabase::storage

::storage/update-bucket(::storage/UpdateBucketRequest({
  bucket_id: "avatars",
  public: false,
  file_size_limit: 1048576
}))

upload

fn (bucket: Str, path: Str, content: Str, content-type: Str): Map
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool): Map
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, opts: Map): Map

Upload a file to a bucket. content is the file content as a string. content-type is the MIME type.

Set upsert: true to overwrite existing files.

Example

::storage ::supabase::storage

result ::storage/upload("avatars", "users/alice.txt", "Hello World", "text/plain", false)
result.Key  // => "avatars/users/alice.txt"

upload-as

fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, access-token: Str): Map
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, access-token: Str, opts: Map): Map

Like upload, but as a signed-in user. access-token is the Bearer token, so row level security applies as that user.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
result ::storage/upload-as("avatars", "users/alice.txt", "Hello World", "text/plain", true, token)
result.Key

upload-response

fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool): ::supabase::api/HttpResponse
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, opts: Map): ::supabase::api/HttpResponse

Like upload, but returns the full HttpResponse. A non-2xx status is not an Err: check status.

Example

::storage ::supabase::storage

response ::storage/upload-response("avatars", "users/alice.txt", "Hello World", "text/plain", true)
response.status

upload-response-as

fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, access-token: Str): ::supabase::api/HttpResponse
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, access-token: Str, opts: Map): ::supabase::api/HttpResponse

Like upload-as, but returns the full HttpResponse. A non-2xx status is not an Err: check status.

Example

::storage ::supabase::storage

token ::hot::ctx/get("supabase.user.token")
response ::storage/upload-response-as("avatars", "users/alice.txt", "Hello World", "text/plain", true, token)
response.status

upload-response-service

fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool): ::supabase::api/HttpResponse
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, opts: Map): ::supabase::api/HttpResponse

Like upload-service, but returns the full HttpResponse. A non-2xx status is not an Err: check status.

Example

::storage ::supabase::storage

response ::storage/upload-response-service("avatars", "users/alice.txt", "Hello World", "text/plain", true)
response.status

upload-service

fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool): Map
fn (bucket: Str, path: Str, content: Str, content-type: Str, upsert: Bool, opts: Map): Map

Like upload, with the service role key, which bypasses row level security. Server-side only.

Example

::storage ::supabase::storage

result ::storage/upload-service("avatars", "users/alice.txt", "Hello World", "text/plain", true)
result.Key

Types

CopyObjectRequest

CopyObjectRequest type {
    bucket_id: Str,
    source_key: Str,
    destination_key: Str,
    destination_bucket: Str?
}

CreateBucketRequest

CreateBucketRequest type {
    name: Str,
    id: Str?,
    public: Bool?,
    file_size_limit: Int?,
    allowed_mime_types: Vec<Str>?
}

ListObjectsRequest

ListObjectsRequest type {
    bucket: Str,
    prefix: Str?,
    limit: Int?,
    offset: Int?,
    search: Str?,
    sort_by: Map?
}

MoveObjectRequest

MoveObjectRequest type {
    bucket_id: Str,
    source_key: Str,
    destination_key: Str,
    destination_bucket: Str?
}

SignedUploadUrlResponse

SignedUploadUrlResponse type {
    url: Str,
    token: Str?
}

SignedUrlResponse

SignedUrlResponse type {
    signedURL: Str
}

StorageBucket

StorageBucket type {
    id: Str?,
    name: Str,
    public: Bool?,
    created_at: Str?,
    updated_at: Str?
}

StorageObject

StorageObject type {
    name: Str,
    id: Str?,
    updated_at: Str?,
    created_at: Str?,
    last_accessed_at: Str?,
    metadata: Map?
}

UpdateBucketRequest

UpdateBucketRequest type {
    bucket_id: Str,
    public: Bool?,
    file_size_limit: Int?,
    allowed_mime_types: Vec<Str>?
}