> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oasm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage

> How OASM uses S3-compatible object storage: the buckets and their access classes, presigned URLs, staged job results, workspace files and quotas

Structured data lives in PostgreSQL. Everything binary or bulky — screenshots, PDF reports, raw job results, workspace files and logos — lives in **S3-compatible object storage**. The Docker Compose deployment ships [RustFS](https://rustfs.com/); any S3-compatible service works.

Storage is not optional: job results pass through it on their way to the inventory, so scans cannot complete without it.

## Buckets and access classes

The core API creates every bucket at startup and gives each one an **access class**. The class decides whether a browser may ever get a URL for an object, and who may.

| Bucket | Class | Holds |
| - | - | - |
| `system` | **public** | The instance logo and connector logos. |
| `cached-static` | **authenticated** | Technology icons. Any signed-in user may read. |
| `screenshot` | **tenant** | Screenshots of web services. Readable by members of a workspace that owns the screenshot. |
| `job-results` | **private** | Raw results staged between a worker and the result processor. |
| `reports` | **private** | Generated PDF reports. |
| `artifacts` | **private** | Workspace files: uploads, files saved by the AI agent, custom scan templates. |

* **Public** objects get stable, unsigned URLs — but only if the public-read policy was verified at startup; otherwise they fall back to a signed URL.
* **Tenant** reads resolve which workspaces own the object and allow a member of any of them. An unknown object is a 404.
* **Private** objects are never reachable through the generic storage routes. Only the domain service that owns them — reports, files, job results — can issue a URL, after it has checked access itself.

## Presigned URLs

The console never streams large files through the core API. It asks for a **presigned URL** and talks to storage directly:

* **Downloads** are signed for a limited time (between one minute and two days). Long-lived URLs are signed against a time rounded to the hour, so repeated requests return the same URL and browsers can cache it.
* **Uploads** use a presigned POST policy that pins the exact size and content type, so the browser cannot upload something other than what the core API approved.
* File downloads are always served as `application/octet-stream` attachments, so a stored file can never render as a page on the console's origin.
* Object keys are validated — no leading `/` or `.`, no `..` — and executable or script extensions are refused.

By default storage is served under the console's own origin (`/api/storage/…`) through the console's reverse proxy, so no extra public hostname or CORS setup is needed. A deployment on cloud S3 can switch to absolute URLs instead. See [Deployment](https://docs.oasm.io/deployment.md#storage-considerations).

## Staged job results

A worker's result is uploaded to the `job-results` bucket before it is processed; the processing queue carries only a reference to the object. This keeps Redis small no matter how large a scan output is, and lets a result survive a core API restart between upload and merge. If a result no longer matches its job — the job was cancelled or re-run meanwhile — the staged object is deleted. A nightly cleanup removes anything left over. See [Results](https://docs.oasm.io/architecture/job-registry.md#results).

## Workspace files and quotas

The **Files** area of a workspace is stored in the `artifacts` bucket under `workspaces/<workspaceId>/…`. The database row, not the object key, holds the display name, sharing (private, shared with members, or public link) and status.

Each workspace has a storage **quota** (1 GiB by default, adjustable per workspace by an admin) and a per-file limit of 50 MiB:

1. Starting an upload **reserves** its size against the quota in the same transaction that creates a `pending` row.
2. Completing the upload moves the bytes from reserved to used.
3. A sweep every five minutes purges uploads that were never completed and releases their reservation.

The quota check is a single conditional update (`used + reserved + size ≤ quota`), never a read followed by a write, so concurrent uploads cannot overshoot it. A deleted upload's row is kept until its upload form has expired, so replaying the form cannot create an object that is not counted.

Custom scan templates are files in a reserved folder of the workspace. When a worker claims a job that uses them, the job registry swaps the template ids for short-lived presigned URLs, so the connector downloads exactly the version that was saved when the job was claimed.

## What happens if storage is lost

The inventory, findings and history are in PostgreSQL, so losing object storage does not lose them. Screenshots come back on the next scan, reports can be regenerated, and connector logos are re-published by the core API when it starts. Workspace files and uploaded templates are the only data that exists in storage alone: back up the storage volume together with the database.

## Related

> [card] [Data model](https://docs.oasm.io/architecture/data-model.md)
>
> What lives in PostgreSQL instead

> [card] [Job registry](https://docs.oasm.io/architecture/job-registry.md)
>
> Where staged results are processed

> [card] [Worker and connector runtime](https://docs.oasm.io/architecture/worker-runtime.md)
>
> Where connector containers fetch custom templates from

> [card] [Deployment](https://docs.oasm.io/deployment.md#storage-considerations)
>
> Volumes, backups and cloud S3


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.