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-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
Creates a time-limited signed download URL for `path`.

## Options

* `:expires-in` — TTL in seconds (required)
* `:download` — see `get-public-url`
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)

Downloads the raw bytes of the object at path from a private bucket.

Returns {:status :body :headers} where :body is a byte array.

Downloads the raw bytes of the object at `path` from a private bucket.

Returns `{:status :body :headers}` where `:body` is a byte array.
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.
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.
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

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

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.

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)
  • :headers — extra HTTP headers
Uploads `body` (bytes / InputStream / File / string) to `path` in the
bucket.

## 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)
* `:headers` — extra HTTP headers
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