Storage

Upload, organize, serve and protect files with the storage module, on local disk, Amazon S3 or Google Cloud Storage, including resumable uploads.

The storage module stores files ("objects") and their metadata. Objects can be referenced from bucket properties of type storage, organized into folders, protected with policies and served with HTTP caching.

The storage browser in the panel with an images folder and two files

Objects

JSON
{
  "_id": "6b0b1b47a5611972c29c2648",
  "name": "cover.png",
  "content": {"type": "image/png", "size": 29159},
  "created_at": "2026-11-28T18:19:51.477Z",
  "updated_at": "2026-11-28T18:19:51.477Z",
  "url": "https://api.example.com/api/storage/cover.png/view"
}
FieldDescription
nameUnique name. Slashes create folders: images/2026/cover.png.
content.typeMIME type.
content.sizeSize in bytes.
urlWhere the content can be downloaded. Depends on the storage strategy.

Upload

Terminal
curl -X POST https://api.example.com/api/storage \
  -H "Authorization: APIKEY <key>" \
  -F "files=@cover.png;type=image/png"

Both forms accept several files in one request and return an array of objects.

Folders

A folder is an empty object whose name ends with /. Create the folder before uploading into it:

JSON
[{"name": "images/", "content": {"type": "", "data": ""}}]
JSON
[{"name": "images/banner.png", "content": {"type": "image/png", "data": "<base64>"}}]

Browse a folder with GET /storage/browse?path=images/.

Resumable uploads

Large files and unreliable networks are better served by resumable uploads. Spica implements the tus protocol at /storage/resumable. Send the file name and type as filename and filetype metadata:

JavaScript
import * as tus from "tus-js-client";

const upload = new tus.Upload(file, {
  endpoint: "https://api.example.com/api/storage/resumable",
  headers: {Authorization: `APIKEY ${key}`},
  metadata: {filename: file.name, filetype: file.type},
  onProgress: (sent, total) => console.log(`${Math.round((sent / total) * 100)}%`),
  onSuccess: () => console.log("Uploaded")
});

upload.start();

Unfinished uploads are discarded after --resumable-upload-expires-in milliseconds (two days by default).

Download

GET/storage/:idOrName/view

The response streams the content with Content-Type, ETag and caching headers, and supports Range, If-None-Match and If-Modified-Since. Requests need an Authorization header.

Terminal
curl https://api.example.com/api/storage/cover.png/view -H "Authorization: APIKEY <key>" -o cover.png

GET /storage/:idOrName returns the metadata only.

List, rename, replace and delete

EndpointActionPurpose
GET /storagestorage:indexList objects. Accepts filter, sort, limit, skip, paginate.
GET /storage/browse?path=storage:browseList one folder.
PATCH /storage/:idstorage:updateRename: {"name": "new-name.png"}.
PUT /storage/:idstorage:updateReplace the content.
DELETE /storage/:idOrNamestorage:deleteDelete one object.
DELETE /storagestorage:deleteDelete several: body ["<id>", "images/old.png"]. Nothing is deleted unless all are allowed.
Terminal
curl -G https://api.example.com/api/storage -H "Authorization: APIKEY <key>" \
  --data-urlencode 'filter={"name": "hello.txt"}' --data-urlencode "paginate=true"
JSON
{"meta": {"total": 1}, "data": [{"_id": "6b0b1b47a5611972c29c264a", "name": "hello.txt", "content": {"type": "text/plain", "size": 11}}]}

Access control

Storage endpoints accept identities and API keys. Use policies to control access, down to folders: storage statements match object ids and names, so an exclusion such as private/* hides a folder.

JSON
{
  "name": "Public Media",
  "description": "Everything except the private folder",
  "statement": [
    {"action": "storage:show", "module": "storage", "resource": {"include": ["*"], "exclude": ["private/*"]}}
  ]
}

To let end users upload files, accept the upload in an HTTP function that checks the user's token and stores the file with an API key.

Storage strategies

Choose where content is kept with --storage-strategy:

StrategyContent lives inObject urlOptions
default--persistent-path/--default-storage-path on the API's disk<default-storage-public-url>/storage/<name>/view--default-storage-path (relative, default storage), --default-storage-public-url (defaults to --public-url)
awss3An S3 buckethttps://<bucket>.s3.<region>.amazonaws.com/<name>--awss3-bucket-name, --awss3-credentials-path (optional, otherwise the AWS default credential chain such as EKS IRSA)
gcloudA Google Cloud Storage buckethttps://storage.googleapis.com/download/storage/v1/b/<bucket>/o/<name>?alt=media--gcloud-bucket-name, --gcloud-service-account-path

With several API replicas, use awss3 or gcloud, or a shared volume, so that every replica sees the same files.

Limits

OptionDefaultEffect
--storage-object-size-limit35Maximum size of one object in MiB.
--storage-total-size-limitMaximum total size of all objects in MB.

Behind a proxy, also raise the proxy's body size limit. The Helm chart sets nginx.ingress.kubernetes.io/proxy-body-size for this.

Referencing files from buckets

A bucket property of type storage stores the object's URL. In the panel, editors pick or upload the file. Over the API, upload the file first and write its url into the document.