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.
(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(copy s opts)Copies an object within or across buckets. Options match move.
Copies an object within or across buckets. Options match `move`.
(create-bucket client id)(create-bucket client id attrs)Creates a new bucket with id and the given attrs.
: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"`
(create-signed-url s path opts)Creates a time-limited signed download URL for path.
:expires-in — TTL in seconds (required):download — see get-public-urlCreates a time-limited signed download URL for `path`. ## Options * `:expires-in` — TTL in seconds (required) * `:download` — see `get-public-url`
(create-signed-urls s paths opts)Creates signed URLs for multiple paths.
:expires-in — TTL in seconds (required):download — applied to every returned URLCreates signed URLs for multiple `paths`. ## Options * `:expires-in` — TTL in seconds (required) * `:download` — applied to every returned URL
(delete-bucket client id)Deletes the bucket and every object inside it.
Deletes the bucket and every object inside it.
(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.(empty-bucket client id)Removes every object from the bucket without deleting it.
Removes every object from the bucket without deleting it.
(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.
(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)(get-bucket client id)Retrieves a bucket by its id.
Retrieves a bucket by its `id`.
(get-public-url s path)(get-public-url s path opts)Builds the public download URL for an object. Does not call the API.
:download — true 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.
(info s path)Retrieves metadata for the object at path.
Retrieves metadata for the object at `path`.
(list-buckets client)Lists all buckets in the project.
Lists all buckets in the project.
(list-files s)(list-files s prefix)(list-files s prefix opts)Lists files in the bucket, optionally filtered by prefix.
:limit — max results (default server-side: 100):offset — pagination offset:sort-by — {:column "name" :order "asc"}:search — substring filterLists 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(move s opts)Moves an object within or across buckets.
: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)
(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.
(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`).
(upload s path body)(upload s path body opts)Uploads body (bytes / InputStream / File / string) to path in the
bucket.
: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 headersUploads `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
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |