Liking cljdoc? Tell your friends :D

supabase.storage

Object storage against Supabase Storage.

Provides bucket CRUD plus per-bucket file operations (list, remove, move, copy, info, exists?, public/signed URLs, upload, download). Per-bucket ops take a storage instance returned by from.

Example

(require '[supabase.core.client :as client]
         '[supabase.storage :as storage])

(def c (client/make-client "https://abc.supabase.co" "anon-key"))

(storage/list-buckets c)
(storage/create-bucket c "avatars" {:public true})

(def s (storage/from c "avatars"))
(storage/upload s "profile.png" my-bytes
                {:content-type "image/png" :upsert true})
(storage/download s "profile.png")
(storage/get-public-url s "profile.png")

Each function returns {:status :body :headers} on success or an anomaly map on failure. See https://supabase.com/docs/reference/javascript/storage-api

Object storage against Supabase Storage.

Provides bucket CRUD plus per-bucket file operations (list, remove, move,
copy, info, exists?, public/signed URLs, upload, download). Per-bucket
ops take a storage instance returned by `from`.

## Example

    (require '[supabase.core.client :as client]
             '[supabase.storage :as storage])

    (def c (client/make-client "https://abc.supabase.co" "anon-key"))

    (storage/list-buckets c)
    (storage/create-bucket c "avatars" {:public true})

    (def s (storage/from c "avatars"))
    (storage/upload s "profile.png" my-bytes
                    {:content-type "image/png" :upsert true})
    (storage/download s "profile.png")
    (storage/get-public-url s "profile.png")

Each function returns `{:status :body :headers}` on success or an anomaly
map on failure. See https://supabase.com/docs/reference/javascript/storage-api
raw docstring

copyclj

(copy s opts)

Copies an object within or across buckets. Options match move.

Copies an object within or across buckets. Options match `move`.
sourceraw docstring

create-bucketclj

(create-bucket client id)
(create-bucket client id attrs)

Creates a new bucket with id and the given attrs.

Attributes (all optional)

  • :public — boolean visibility flag (default false)
  • :file-size-limit — max file size in bytes
  • :allowed-mime-types — vector of allowed MIME types or wildcards
  • :type"STANDARD" (default) or "ANALYTICS"
Creates a new bucket with `id` and the given `attrs`.

## Attributes (all optional)

* `:public` — boolean visibility flag (default false)
* `:file-size-limit` — max file size in bytes
* `:allowed-mime-types` — vector of allowed MIME types or wildcards
* `:type` — `"STANDARD"` (default) or `"ANALYTICS"`
sourceraw docstring

create-signed-upload-urlclj

(create-signed-upload-url s path)
(create-signed-upload-url s path opts)

Creates a signed URL that lets a client upload to path without further authentication. Valid for two hours.

Options

  • :upsert — allow overwriting an existing object (default false)

On success returns {:status :body :headers} where :body is {:signed-url <url> :token <token> :path <clean-path>}. The token can be fed to upload-to-signed-url.

Creates a signed URL that lets a client upload to `path` without
further authentication. Valid for two hours.

## Options

* `:upsert` — allow overwriting an existing object (default false)

On success returns `{:status :body :headers}` where `:body` is
`{:signed-url <url> :token <token> :path <clean-path>}`. The token can
be fed to `upload-to-signed-url`.
sourceraw docstring

create-signed-urlclj

(create-signed-url s path opts)

Creates a time-limited signed download URL for path.

Options

  • :expires-in — TTL in seconds (required)
  • :download — see get-public-url
  • :transform — image transform map applied to the signed asset
Creates a time-limited signed download URL for `path`.

## Options

* `:expires-in` — TTL in seconds (required)
* `:download` — see `get-public-url`
* `:transform` — image transform map applied to the signed asset
sourceraw docstring

create-signed-urlsclj

(create-signed-urls s paths opts)

Creates signed URLs for multiple paths.

Options

  • :expires-in — TTL in seconds (required)
  • :download — applied to every returned URL
Creates signed URLs for multiple `paths`.

## Options

* `:expires-in` — TTL in seconds (required)
* `:download` — applied to every returned URL
sourceraw docstring

delete-bucketclj

(delete-bucket client id)

Deletes the bucket and every object inside it.

Deletes the bucket and every object inside it.
sourceraw docstring

downloadclj

(download s path)
(download s path opts)

Downloads the object at path from a private bucket.

Returns {:status :body :headers}. By default :body is a byte array; pass :response-as :stream to receive a java.io.InputStream (the caller is responsible for closing it).

Options

  • :response-as:byte-array (default) or :stream
  • :range[start end] inclusive byte range for a partial download
  • :transform — image transform map (renders via render/image)
  • :headers — extra request headers
Downloads the object at `path` from a private bucket.

Returns `{:status :body :headers}`. By default `:body` is a byte
array; pass `:response-as :stream` to receive a `java.io.InputStream`
(the caller is responsible for closing it).

## Options

* `:response-as` — `:byte-array` (default) or `:stream`
* `:range` — `[start end]` inclusive byte range for a partial download
* `:transform` — image transform map (renders via render/image)
* `:headers` — extra request headers
sourceraw docstring

empty-bucketclj

(empty-bucket client id)

Removes every object from the bucket without deleting it.

Removes every object from the bucket without deleting it.
sourceraw docstring

exists?clj

(exists? s path)

Returns true if the object exists, false otherwise. Errors other than not-found are still surfaced as false — call info if you need detail.

Returns true if the object exists, false otherwise. Errors other than
not-found are still surfaced as false — call `info` if you need detail.
sourceraw docstring

fromclj

(from client bucket-id)

Returns a storage instance bound to bucket-id. Pass it as the first argument to file operations.

(def s (from client "avatars"))
(list-files s)
Returns a storage instance bound to `bucket-id`. Pass it as the first
argument to file operations.

    (def s (from client "avatars"))
    (list-files s)
sourceraw docstring

get-bucketclj

(get-bucket client id)

Retrieves a bucket by its id.

Retrieves a bucket by its `id`.
sourceraw docstring

get-public-urlclj

(get-public-url s path)
(get-public-url s path opts)

Builds the public download URL for an object. Does not call the API.

Options

  • :downloadtrue triggers browser download with the object's name; a string sets a custom download filename.
  • :transform — image transform map; routes through the image render endpoint and appends the transform query.
Builds the public download URL for an object. Does not call the API.

## Options

* `:download` — `true` triggers browser download with the object's name;
  a string sets a custom download filename.
* `:transform` — image transform map; routes through the image render
  endpoint and appends the transform query.
sourceraw docstring

infoclj

(info s path)

Retrieves metadata for the object at path.

Retrieves metadata for the object at `path`.
sourceraw docstring

list-bucketsclj

(list-buckets client)

Lists all buckets in the project.

Lists all buckets in the project.
sourceraw docstring

list-filesclj

(list-files s)
(list-files s prefix)
(list-files s prefix opts)

Lists files in the bucket, optionally filtered by prefix.

Options

  • :limit — max results (default server-side: 100)
  • :offset — pagination offset
  • :sort-by{:column "name" :order "asc"}
  • :search — substring filter
Lists files in the bucket, optionally filtered by `prefix`.

## Options

* `:limit` — max results (default server-side: 100)
* `:offset` — pagination offset
* `:sort-by` — `{:column "name" :order "asc"}`
* `:search` — substring filter
sourceraw docstring

list-files-v2clj

(list-files-v2 s)
(list-files-v2 s prefix)
(list-files-v2 s prefix opts)

Lists files using cursor-based pagination (the list-v2 endpoint).

Cursor pagination is O(1) regardless of position, unlike the offset-based list-files.

Options

  • :limit — page size (default server-side 100)
  • :cursor — pagination cursor from a previous response
  • :with-delimiter — group results by folder hierarchy when true
Lists files using cursor-based pagination (the `list-v2` endpoint).

Cursor pagination is O(1) regardless of position, unlike the
offset-based `list-files`.

## Options

* `:limit` — page size (default server-side 100)
* `:cursor` — pagination cursor from a previous response
* `:with-delimiter` — group results by folder hierarchy when true
sourceraw docstring

moveclj

(move s opts)

Moves an object within or across buckets.

Options

  • :from — source path (required)
  • :to — destination path (required)
  • :destination-bucket — target bucket id (optional, same bucket if omitted)
Moves an object within or across buckets.

## Options

* `:from` — source path (required)
* `:to` — destination path (required)
* `:destination-bucket` — target bucket id (optional, same bucket if omitted)
sourceraw docstring

removeclj

(remove s paths)

Deletes one or more objects from the bucket.

paths may be a single path string or a vector of paths.

Deletes one or more objects from the bucket.

`paths` may be a single path string or a vector of paths.
sourceraw docstring

updateclj

(update s path body)
(update s path body opts)

Replaces the object at path with body via PUT. Unlike upload, this targets an existing object. Same options as upload.

Replaces the object at `path` with `body` via PUT. Unlike `upload`,
this targets an existing object. Same options as `upload`.
sourceraw docstring

update-bucketclj

(update-bucket client id attrs)

Updates the bucket identified by id with attrs.

Same attributes as create-bucket (without :id).

Updates the bucket identified by `id` with `attrs`.

Same attributes as `create-bucket` (without `:id`).
sourceraw docstring

uploadclj

(upload s path body)
(upload s path body opts)

Uploads body (bytes / InputStream / File / string) to path in the bucket via POST. Fails if the object already exists unless :upsert.

Options

  • :content-type — defaults to "text/plain;charset=UTF-8"
  • :cache-control — number of seconds (default "3600")
  • :upsert — overwrite if the object exists (default false)
  • :metadata — map of string→string stored as object metadata
  • :headers — extra HTTP headers
Uploads `body` (bytes / InputStream / File / string) to `path` in the
bucket via POST. Fails if the object already exists unless `:upsert`.

## Options

* `:content-type` — defaults to `"text/plain;charset=UTF-8"`
* `:cache-control` — number of seconds (default `"3600"`)
* `:upsert` — overwrite if the object exists (default false)
* `:metadata` — map of string→string stored as object metadata
* `:headers` — extra HTTP headers
sourceraw docstring

upload-to-signed-urlclj

(upload-to-signed-url s path token body)
(upload-to-signed-url s path token body opts)

Uploads body to a previously created signed upload URL using its token (see create-signed-upload-url). Same options as upload.

Uploads `body` to a previously created signed upload URL using its
`token` (see `create-signed-upload-url`). Same options as `upload`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close