Skip to main content

Storage API reference

The Storage API at https://<ref>.baas.arianet.app/storage/v1 manages the Project's files and is compatible with the common client libraries. Each request runs with the role of its key or User, and Policies on storage.objects decide who can see or write which file (RLS on files).

BAAS_URL=https://<ref>.baas.arianet.app
ANON_KEY=<ANON_KEY>

Headers as in the REST API: always apikey, plus Authorization: Bearer <access_token> for a signed-in User. The Service Key bypasses Policies.

Buckets​

RequestPurpose
GET /storage/v1/bucketList Buckets
GET /storage/v1/bucket/<id>One Bucket
POST /storage/v1/bucketCreate: {"id": "avatars", "name": "avatars", "public": false, "file_size_limit": 5242880, "allowed_mime_types": ["image/*"]}
PUT /storage/v1/bucket/<id>Change public, file_size_limit (null removes the limit) or allowed_mime_types
POST /storage/v1/bucket/<id>/emptyDelete every file in the Bucket
DELETE /storage/v1/bucket/<id>Delete an empty Bucket (not empty: 409)

Buckets are usually created and changed in the panel or with the Service Key. A Bucket name starts with a letter or digit and has English letters and digits, _, . and -. Do not name a Bucket public, authenticated, info, sign, upload, list, move or copy (they clash with API paths).

Upload​

POST /storage/v1/object/{bucket}/{path}​

curl -X POST "$BAAS_URL/storage/v1/object/avatars/<user-id>/avatar.png" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: image/png" \
--data-binary @avatar.png
  • The body is the file itself (or a multipart form). Answer: {"Id": "…", "Key": "avatars/<user-id>/avatar.png"}.
  • To replace an existing file send x-upsert: true, or use PUT on the same path; without it a duplicate name is an error.
  • cache-control (such as max-age=3600) is stored with the file and sent on download.
  • Limits: the smaller of the Plan's limit (50 MB on the Free Plan) and the Bucket's own file_size_limit. A bigger file: 413. A type not in allowed_mime_types: 415. The Free Plan's total Storage quota is full: 413 with code: "QuotaExceeded".
  • A file name is 1 to 1024 bytes with no leading, trailing or doubled / and no . or .. segment. Folders are just path segments and are not created separately.

Download​

RequestAccess
GET /storage/v1/object/public/<bucket>/<path>public Buckets only; no key
GET /storage/v1/object/authenticated/<bucket>/<path>by Policy, with key and token
GET /storage/v1/object/sign/<bucket>/<path>?token=…with a Signed URL, no key
GET /storage/v1/object/info/<bucket>/<path>file details: size, type, etag, timestamps
  • ?download sends the file as an attachment; ?download=name.png with a chosen name.
  • Range and If-None-Match headers are supported.
  • HTML, SVG, XML and JavaScript files are always sent as attachments on the Free Plan.
<img src="https://<ref>.baas.arianet.app/storage/v1/object/public/site-images/logo.png" alt="logo">

List, move and delete​

RequestPurpose
POST /storage/v1/object/list/<bucket>List one folder level: {"prefix": "users/42/", "limit": 100, "offset": 0, "sortBy": {"column": "name", "order": "asc"}, "search": ""}. Folders come back with id: null.
POST /storage/v1/object/moveMove or rename: {"bucketId": "avatars", "sourceKey": "a.png", "destinationKey": "b.png"} (with destinationBucket to another Bucket)
POST /storage/v1/object/copyCopy, same body
DELETE /storage/v1/object/<bucket>/<path>Delete one file
DELETE /storage/v1/object/<bucket>Delete several files: {"prefixes": ["a.png", "docs/b.pdf"]}

Signed URLs​

A Signed URL is a temporary link anyone can use to download the file, without a key or sign-in, until it expires. Whoever creates it must be allowed to read (select) that file by a Policy.

POST /storage/v1/object/sign/{bucket}/{path}​

curl -X POST "$BAAS_URL/storage/v1/object/sign/documents/<user-id>/report.pdf" \
-H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"expiresIn": 3600}'

The answer is {"signedURL": "/object/sign/documents/…/report.pdf?token=…"}; the full link is https://<ref>.baas.arianet.app/storage/v1 + signedURL.

  • expiresIn in seconds, from 1 second to 7 days.
  • Several files at once: POST /storage/v1/object/sign/<bucket> with {"expiresIn": 600, "paths": ["a.pdf", "b.pdf"]}.
  • Each link is valid only for that Project, that file and that action (download), and cannot be tampered with.

Signed uploads (for example, uploading straight from a browser without handing over a token): POST /storage/v1/object/upload/sign/<bucket>/<path> returns {url, token} (the creator must be allowed to insert); then send the file with PUT /storage/v1/object/upload/sign/<bucket>/<path>?token=…. The link is valid for 2 hours.

RLS on files​

File details live in the storage.buckets and storage.objects Tables in the Project's own Database, and RLS is on for both with no Policy. Until you write a Policy, anon and authenticated cannot see or upload any file; only the Service Key (and the panel) can. A public Bucket only opens downloads from the public path; listing, uploading and deleting still need Policies.

Write Policies on storage.objects in the SQL Editor. Useful columns: bucket_id, name (the file's full path) and owner_id. Helper functions: storage.foldername(name) (the array of folders), storage.filename(name) and storage.extension(name).

Example: in the avatars Bucket, each User can upload, see, replace and delete files only in a folder named after their own id:

create policy "avatars: read own folder" on storage.objects
for select to authenticated
using (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);

create policy "avatars: upload to own folder" on storage.objects
for insert to authenticated
with check (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);

create policy "avatars: replace own files" on storage.objects
for update to authenticated
using (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);

create policy "avatars: delete own files" on storage.objects
for delete to authenticated
using (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);
ActionPolicy needed
Download (non-public), list, create a Signed URLselect
Uploadinsert
Upload with x-upsert (replace)insert, select and update
Move and renameselect and update
Deleteselect and delete

For a private Bucket that everyone signed in may read but only its owners may write to, use bucket_id = '…' alone instead of the folder condition in the select Policy.

Resumable uploads (TUS)​

For large files or unstable connections, use the standard TUS 1.0 protocol at POST /storage/v1/upload/resumable; any TUS client library (such as tus-js-client or Uppy) works. If the connection drops, the upload continues where it stopped.

import * as tus from 'tus-js-client'

const upload = new tus.Upload(file, {
endpoint: 'https://<ref>.baas.arianet.app/storage/v1/upload/resumable',
headers: { authorization: `Bearer ${accessToken}`, apikey: ANON_KEY, 'x-upsert': 'true' },
metadata: { bucketName: 'videos', objectName: `${userId}/intro.mp4`, contentType: 'video/mp4' },
chunkSize: 6 * 1024 * 1024,
onProgress: (sent, total) => console.log(Math.round((sent / total) * 100) + '%'),
})
upload.start()
  • Metadata: bucketName, objectName, contentType, cacheControl and metadata (JSON).
  • Policies, the Bucket's file size and type limits and the Plan's quota are checked when the upload starts, and Policies again when it finishes.
  • An upload is valid for 24 hours and only whoever started it can continue it.

Image transformation​

Resize or crop an image on download, without storing separate copies:

GET /storage/v1/render/image/public/<bucket>/<path>?width=400&height=400&resize=cover&quality=75
GET /storage/v1/render/image/authenticated/<bucket>/<path>?width=200 (with a token, per Policy)
ParameterValue
width, height1 to 2500 pixels; with only one of them the aspect ratio is kept
resizecover (crop to fill the box), contain (fit inside the box), fill (stretch)
quality20 to 100, default 80
  • Input JPEG, PNG, GIF (first frame only) and WebP; output JPEG or PNG (a transparent image stays PNG).
  • The source image is at most 25 MB and 25 megapixels. Results are cached.
  • Signed URL with a transformation: pass transform to POST /storage/v1/object/sign/<bucket>/<path> (such as {"expiresIn": 3600, "transform": {"width": 200}}); the link opens only the transformed version, not the original file.
  • Image transformation is not on the Free Plan (403 FeatureNotEnabled).

S3 access​

https://<ref>.baas.arianet.app/storage/v1/s3 is an S3-compatible endpoint (path-style, any Region name accepted, Signature Version 4). Create a key in the S3 access tab.

export AWS_ACCESS_KEY_ID=<access-key-id> AWS_SECRET_ACCESS_KEY=<secret>
aws s3 cp ./report.pdf s3://documents/2026/report.pdf --endpoint-url https://<ref>.baas.arianet.app/storage/v1/s3
  • S3 requests run with the Service Key's access and bypass Policies; Bucket limits, the Plan's file size and the quota still apply. A key works only for its own Project.
  • Supported: list, create (private) and delete empty Buckets; list, upload, copy, download (with Range) and delete files; batch delete; and multipart uploads (at most 7 days). ACLs, tagging and versioning are not supported (501).