JavaScript: Storage
Create buckets, upload and download files, list and move objects, and hand out public or signed URLs with @sovaria/sdk.
sovaria.storage stores files in buckets. Each bucket has rules (who may read and write which paths), a size limit and allowed types; a public bucket's files have permanent URLs, a private bucket's files are read through the API or a time-limited signed URL.
import { createClient } from '@sovaria/sdk'
const sovaria = createClient('https://<project-ref>.sovarias.in', '<anon-key>')
const user = sovaria.auth.getSession()?.user
await sovaria.storage.upload('avatars', `${user.id}/avatar.png`, file, { upsert: true, contentType: 'image/png' })
// public bucket: a permanent URL
img.src = sovaria.storage.publicUrl('avatars', `${user.id}/avatar.png`)
// private bucket: a link that works for one hour
const { url } = await sovaria.storage.signDownload('invoices', `${user.id}/2026-10.pdf`, 3600)#sovaria.storage
sovaria.storage.from
One bucket, supabase-js style: const { data, error } = await sovaria.storage.from('avatars').upload(path, file).
sovaria.storage.from(bucket: string): StorageBucketEvery call resolves to { data, error } and never throws, except getPublicUrl() (sync, like supabase-js).
Parameters
bucketstringrequired
Returns
StorageBucket — A bucket with supabase-js's calls: upload (cacheControl, upsert, contentType), update, download ({ transform }), remove, list, move, copy, info, exists, getPublicUrl ({ download, transform }), createSignedUrl(s), createSignedUploadUrl, uploadToSignedUrl. Every call resolves to { data, error } except getPublicUrl.
const avatars = sovaria.storage.from('avatars')
await avatars.upload(`${userId}/me.png`, file, { upsert: true, cacheControl: '3600' })
const { data } = avatars.getPublicUrl(`${userId}/me.png`, { transform: { width: 128, height: 128 } })
await avatars.copy(`${userId}/me.png`, `${userId}/backup.png`)
const { data: link } = await avatars.createSignedUploadUrl(`${userId}/big.mov`)
await avatars.uploadToSignedUrl(`${userId}/big.mov`, link.token, movie)sovaria.storage.request
Request.
sovaria.storage.request(
method: string,
path: string,
options?: RequestOptions = {},
): Promise<JsonValue>Parameters
methodstringrequiredpathstringrequiredoptionsRequestOptionsoptionaldefault{}
Returns
Promise<JsonValue>
sovaria.storage.putJson
Put json.
sovaria.storage.putJson(
path: string,
payload: JsonObject,
): Promise<JsonValue>Parameters
pathstringrequiredpayloadJsonObjectrequired
Returns
Promise<JsonValue>
- HTTP
POST /api/v1/store/{…}
sovaria.storage.get
Get.
sovaria.storage.get(
path: string,
query?: Record<string, string | number | boolean | null | undefined>,
): Promise<JsonValue>Parameters
pathstringrequiredqueryRecord<string, string | number | boolean | null | undefined>optional
Returns
Promise<JsonValue>
- HTTP
GET /api/v1/store/{…}
sovaria.storage.delete
Delete.
sovaria.storage.delete(path: string): Promise<JsonValue>Parameters
pathstringrequired
Returns
Promise<JsonValue>
- HTTP
DELETE /api/v1/store/{…}
sovaria.storage.publicUrl
Public URL of an object in a public bucket (no token needed; safe to put in <img src>).
sovaria.storage.publicUrl(
bucket: string,
objectPath: string,
projectId?: string,
): stringParameters
bucketstringrequired- A public bucket.
objectPathstringrequired- Object path.
projectIdstringoptional- Only when the client has no project scope.
Returns
string — A permanent URL string. No network call.
sovaria.storage.listBuckets
Every bucket.
sovaria.storage.listBuckets(
): Promise<JsonValue> | Promise<ParityResult<Bucket[] | null>>In results: 'supabase' mode { data: Bucket[], error } (supabase-js).
Returns
Promise<JsonValue> | Promise<ParityResult<Bucket[] | null>>
sovaria.storage.createBucket
supabase-js: createBucket('avatars', { public: true, fileSizeLimit: '5MB', allowedMimeTypes: ['image/*'] }) → { data: { name }, error }.
sovaria.storage.createBucket(
idOrBody: string | JsonObject,
options?: BucketOptions = {},
): Promise<JsonObject> | Promise<ParityResult<{ name: string; } | null>>The older form takes the request body ({ name, public, file_size_limit, … }).
Parameters
idOrBodystring | JsonObjectrequired- supabase-js's form: the bucket id, then
{ public, fileSizeLimit, allowedMimeTypes }→{ data, error }. The older form: one object{ name, public, file_size_limit, allowed_mime_types }. optionsBucketOptionsoptionaldefault{}public,fileSizeLimit(bytes or'5MB'),allowedMimeTypes(image/*patterns).
Returns
Promise<JsonObject> | Promise<ParityResult<{ name: string; } | null>>
const { error } = await sovaria.storage.createBucket('avatars', { public: true, fileSizeLimit: '2MB', allowedMimeTypes: ['image/png', 'image/jpeg'] })sovaria.storage.getBucket
One bucket.
sovaria.storage.getBucket(
name: string,
): Promise<JsonObject> | Promise<ParityResult<Bucket | null>>In results: 'supabase' mode { data: Bucket, error }.
Parameters
namestringrequired
Returns
Promise<JsonObject> | Promise<ParityResult<Bucket | null>>
sovaria.storage.updateBucket
Change a bucket.
sovaria.storage.updateBucket(
name: string,
body: JsonObject | BucketOptions,
): Promise<JsonObject> | Promise<ParityResult<{ message: string; } | null>>supabase-js's options ({ public, fileSizeLimit, allowedMimeTypes }) in results: 'supabase' mode; otherwise the request body ({ public, file_size_limit, allowed_mime_types }).
Parameters
namestringrequiredbodyJsonObject | BucketOptionsrequired
Returns
Promise<JsonObject> | Promise<ParityResult<{ message: string; } | null>>
sovaria.storage.deleteBucket
Delete a bucket and its files (project admins).
sovaria.storage.deleteBucket(
name: string,
): Promise<JsonObject> | Promise<ParityResult<{ message: string; } | null>>In results: 'supabase' mode { data, error }.
Parameters
namestringrequired
Returns
Promise<JsonObject> | Promise<ParityResult<{ message: string; } | null>>
sovaria.storage.emptyBucket
Delete every file in a bucket and keep the bucket (project admins): { data, error }.
sovaria.storage.emptyBucket(
name: string,
): Promise<ParityResult<{ message: string; } | null>>Parameters
namestringrequired
Returns
Promise<ParityResult<{ message: string; } | null>> — { data, error } once every file is deleted (the bucket stays). Project admins only.
sovaria.storage.listObjects
List objects.
sovaria.storage.listObjects(
bucket: string,
query?: { prefix?: string },
): Promise<JsonValue>Parameters
bucketstringrequiredquery{ prefix?: string }optionalprefix: only objects under this folder.
Returns
Promise<JsonValue>
[
{
"name": "6e19c0a2-3f5b-4a8e-9b1d-0c7f2e8a4d51/photo.png",
"size": 48213,
"content_type": "image/png",
"created_at": "2026-10-17T13:02:44Z",
"updated_at": "2026-10-17T13:02:44Z",
"checksum": "9e107d9d372bb6826bd81d3542a419d6"
}
]sovaria.storage.signDownload
Sign download.
sovaria.storage.signDownload(
bucket: string,
objectPath: string,
expiresIn?: number = 3600,
download?: boolean | string,
): Promise<JsonObject>Parameters
bucketstringrequiredobjectPathstringrequiredexpiresInnumberoptionaldefault3600- Seconds the link stays valid.
downloadboolean | stringoptional
Returns
Promise<JsonObject> — { url, expires_at }.
{
"url": "https://<storage-host>/<object>?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=600&X-Amz-Signature=…",
"expires_at": "2026-10-17T13:14:44Z",
"method": "GET"
}sovaria.storage.signUpload
Signed upload URL.
sovaria.storage.signUpload(
bucket: string,
objectPath: string,
expiresIn?: number = 3600,
options?: { sizeBytes?: number; contentType?: string } = {},
): Promise<JsonObject>Pass sizeBytes (the file's exact size) to get a direct-to-storage URL bound to that size; without it the URL uploads through Sovaria, which checks the size limits as the bytes arrive.
Parameters
bucketstringrequiredobjectPathstringrequiredexpiresInnumberoptionaldefault3600- Seconds the upload URL stays valid.
options{ sizeBytes?: number; contentType?: string }optionaldefault{}
Returns
Promise<JsonObject> — A URL a browser can upload to directly, without your server in the middle.
{
"url": "https://<storage-host>/<object>?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=900&X-Amz-Signature=…",
"expires_at": "2026-10-17T13:19:44Z",
"method": "PUT"
}sovaria.storage.moveObject
Move object.
sovaria.storage.moveObject(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired- Source and destination bucket/path.
Returns
Promise<JsonObject>
{
"status": "moved",
"from": "avatars/6e19c0a2-3f5b-4a8e-9b1d-0c7f2e8a4d51/old.png",
"to": "avatars/6e19c0a2-3f5b-4a8e-9b1d-0c7f2e8a4d51/new.png"
}sovaria.storage.upload
Upload a file.
sovaria.storage.upload(
bucket: string,
objectPath: string,
file: Blob,
options?: { upsert?: boolean; contentType?: string; cacheControl?: string | number } = {},
): Promise<JsonObject>Bucket rules decide who may write where — e.g. with the "Own folder" rule a user writes to ${userId}/…. Pass upsert: true to replace an existing object.
Parameters
bucketstringrequired- Bucket name.
objectPathstringrequired- Path inside the bucket, e.g.
<user-id>/avatar.png. Bucket rules often require the first folder to be the user's id. fileBlobrequired- A
BloborFile. options{ upsert?: boolean; contentType?: string; cacheControl?: string | number }optionaldefault{}upsert: overwrite an existing object;contentType: MIME type stored with the object.
Returns
Promise<JsonObject>
- HTTP
POST /api/v1/store/objects/{…}
- Over the bucket's size limit or type list the server answers
413/415.
sovaria.storage.download
Download an object the caller may read, as a Blob.
sovaria.storage.download(
bucket: string,
objectPath: string,
): Promise<Blob>Parameters
bucketstringrequiredobjectPathstringrequired
Returns
Promise<Blob> — A Blob.
const blob = await sovaria.storage.download('invoices', path)
const href = URL.createObjectURL(blob)Response
[
{
"name": "6e19c0a2-3f5b-4a8e-9b1d-0c7f2e8a4d51/photo.png",
"size": 48213,
"content_type": "image/png",
"created_at": "2026-10-17T13:02:44Z",
"updated_at": "2026-10-17T13:02:44Z",
"checksum": "9e107d9d372bb6826bd81d3542a419d6"
}
]sovaria.storage.remove
Delete an object.
sovaria.storage.remove(
bucket: string,
objectPath: string,
): Promise<JsonObject>Parameters
bucketstringrequired- Bucket name.
objectPathstringrequired- Object path.
Returns
Promise<JsonObject>
- HTTP
DELETE /api/v1/store/objects/{…}