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-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.
: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`.(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-url:transform — image transform map applied to the signed assetCreates 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
(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)(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).
: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 headersDownloads 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(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.: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.
(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(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.
:limit — page size (default server-side 100):cursor — pagination cursor from a previous response:with-delimiter — group results by folder hierarchy when trueLists 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
(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 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`.
(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 via POST. Fails if the object already exists unless :upsert.
: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 headersUploads `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
(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`.
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 |