Storage providers and your own S3
Storage speaks plain S3 and never handles file bytes: it issues presigned URLs and the browser talks to the object store directly. So any S3-compatible store works. There are two levels:
- Your own S3 per project (BYO): you attach a bucket you own to a project. For everyone.
- Instance storage: the object store behind a whole deployment. This is for people who run PotaLab Base themselves; on Cloud it is managed for you.
Your own S3 per project
Section titled “Your own S3 per project”A project can have several storage backends. Each Base bucket is bound to exactly one backend when you create it; without a choice it uses the deployment default.
Know these first:
- Quota: objects on your backend do not count toward the project’s storage quota. You pay the provider for the bytes. Requests still count toward the signed-URL rate limits.
- Fixed once used: a bucket that has objects cannot change backend, and the backend’s endpoint, bucket and key prefix cannot change either (
409 bucket_has_objects). Base does not move data. To migrate, create a new Base bucket on the new backend, copy withrcloneoraws s3 sync, then switch your app. - No silent fallback: if a backend is
disabledor unreachable, its buckets answer503 backend_unavailable. Data is never written to the default store by mistake. - Deleting is safe: deleting a backend removes only its configuration and secret, never data at the provider. It is refused while Base buckets still use it (
409 backend_in_use).
Prepare your bucket
Section titled “Prepare your bucket”- Create the bucket and an access key limited to it: read, write, delete and list.
- If the bucket holds other data too, choose a
key_prefixsuch asbase/. Base only touches keys under<key_prefix><bucket_id>/. - Allow your app origin in the bucket CORS (below), or set
manage_buckettotruewhere the key may change CORS.
| Provider | endpoint |
region |
force_path_style |
|---|---|---|---|
s3 (AWS) |
https://s3.<region>.amazonaws.com |
the bucket region | false |
r2 (Cloudflare) |
https://<account_id>.r2.cloudflarestorage.com |
auto |
true |
minio |
your MinIO URL | us-east-1 |
true |
generic (Backblaze B2, Wasabi, Ceph, …) |
the provider’s S3 endpoint | as documented | usually true |
[{ "AllowedOrigins": ["https://app.example.com"], "AllowedMethods": ["GET", "PUT", "HEAD"], "AllowedHeaders": ["*"], "ExposeHeaders": ["ETag"], "MaxAgeSeconds": 3600}]Add a backend
Section titled “Add a backend”In the dashboard: Storage → Backends → Add backend. Or with the Management API:
curl -X POST "$BASE_API/v1/projects/$REF/storage/backends" \ -H "Authorization: Bearer $PAT" -H "Content-Type: application/json" \ -d '{ "name": "media-r2", "provider": "r2", "endpoint": "https://<account_id>.r2.cloudflarestorage.com", "region": "auto", "bucket": "my-media", "key_prefix": "base/", "force_path_style": true, "access_key_id": "'"$S3_KEY_ID"'", "secret_access_key": "'"$S3_SECRET"'" }'name uses a-z0-9_- and cannot be default. key_prefix is empty or ends with /. The secret is write-only: responses show has_secret and the last 4 characters of the key id, never the secret. To rotate it, PATCH the backend with a new secret_access_key; it takes effect immediately. Secrets are encrypted with the project’s data key.
Verify
Section titled “Verify”Creating or editing a backend runs a check. Run it again with POST /v1/projects/$REF/storage/backends/{id}/verify (10 per minute per project). It checks the address, the bucket, a test write and delete, and listing. Only a backend with status: ok can be given to a new bucket (409 backend_unverified).
Failures use fixed codes, never the provider’s raw reply:
| Code | Fix |
|---|---|
dns_failed |
the host does not resolve; check the endpoint |
blocked_address |
the host is private, loopback or link-local |
tls_error |
invalid certificate or hostname mismatch |
connect_timeout, connect_failed |
network or firewall |
auth_failed |
wrong key id or secret |
no_such_bucket |
create the bucket |
access_denied |
the key lacks a permission on the bucket or prefix |
wrong_region |
set the bucket’s region |
write_failed |
the test object could not be written, read or deleted |
Use it
Section titled “Use it”Create a bucket on the backend with the secret key (the dashboard’s bucket form has a Backend field, and the SDK’s createBucket takes a backend option), then upload as usual. The signed URL points at your provider.
// server side, secret key. `backend` is the name or id of a verified backend; omit it (or pass "default") for the deployment's own storeconst { data: bucket, error } = await base.storage.createBucket("media", { backend: "media-r2", public: false })// bucket.backend -> { id, name } for your own S3, null for the default storeThe same call over REST:
curl -X POST "$BASE_URL/storage/v1/bucket" -H "Authorization: Bearer $SECRET_KEY" -H "apikey: $SECRET_KEY" \ -H "Content-Type: application/json" -d '{"id":"media","backend":"media-r2"}'const { error } = await base.storage.from("media").upload(`${userId}/photo.png`, file, { contentType: "image/png" })Security
Section titled “Security”- Your endpoint is treated as untrusted input. Base resolves it, refuses it if any address is private, loopback, link-local or a cloud metadata address, connects to exactly the address it checked, and follows no redirects. Only
httpsis accepted by default. - Give the key only the bucket and prefix it needs. Do not reuse an account-wide root key.
- Creating, changing, deleting and verifying a backend is audited (who, endpoint host, never the secret).
- Public access you grant at the provider (an R2 custom domain, a CDN, a public policy) is outside Base’s control.
- Signed URLs are bearer links until they expire (upload 600 s, download 300 s by default).
- Uploads are one presigned PUT up to 5 GiB; there is no multipart yet. Your provider’s own single-PUT limit also applies.
Instance storage (self-hosting)
Section titled “Instance storage (self-hosting)”If you run PotaLab Base yourself, BASE_STORAGE_PROVIDER chooses a capability preset, and the S3 connection comes from BASE_STORAGE_S3_*. Storage is on only when BASE_STORAGE_S3_ENDPOINT is set.
| Preset | Creates buckets | Public bucket policy | Bucket CORS API | Path-style default | Public buckets via |
|---|---|---|---|---|---|
rustfs (default) |
yes | yes | yes | yes | policy |
minio |
yes | yes | no (server-wide CORS) | yes | policy |
s3 (AWS) |
yes (needs IAM) | yes, if Block Public Access is off | yes | no | off by default |
r2 (Cloudflare) |
yes (admin token) | no | yes | yes | public-url |
generic |
no | no | no | yes | off |
A setting that contradicts the preset stops the API at startup with the list of wrong variables. BASE_STORAGE_BUCKET_MODE is per-project (one bucket per project, the default) or shared (one bucket, keys <BASE_STORAGE_SHARED_PREFIX><project_id>/<bucket_id>/<path>, set BASE_STORAGE_SHARED_BUCKET). Prefer shared on AWS S3 and R2, where bucket names are global and counts are limited. Switching mode does not move existing files.
# Cloudflare R2, one shared bucketBASE_STORAGE_PROVIDER=r2BASE_STORAGE_S3_ENDPOINT=https://<account_id>.r2.cloudflarestorage.comBASE_STORAGE_S3_PUBLIC_URL=https://<account_id>.r2.cloudflarestorage.comBASE_STORAGE_S3_REGION=autoBASE_STORAGE_BUCKET_MODE=sharedBASE_STORAGE_SHARED_BUCKET=<your r2 bucket>BASE_STORAGE_MANAGE_BUCKET=falseBASE_STORAGE_PUBLIC_READ=public-urlBASE_STORAGE_PUBLIC_BASE_URL=https://files.example.comIf a provider cannot do something, Base says so instead of ignoring it: creating a public bucket where public policies are unsupported answers 409 storage_public_not_supported, and a refused bucket creation answers bucket_create_denied. To let BYO backends live on a private network such as a MinIO in your LAN, list the network in BASE_STORAGE_BYO_ALLOW_PRIVATE_NETWORKS; empty means blocked.