# Storage buckets (S3)

> S3-compatible storage for files — images, uploads, backups. Keys are given to your services automatically.

Source: https://livops.dev/en/docs/storage

A storage bucket is a place for files: user-uploaded images, reports, backups. It's compatible with the S3 API, so the AWS SDK, `boto3`, `@aws-sdk/client-s3` or `rclone` work unchanged.

## Create a storage bucket

In a project environment, click **Add storage bucket**. The bucket is named `<project>-<environment>-<name>`, for example `shop-production-files`.

## Variables

For the first storage bucket in an environment, the following are written to services:

```bash
S3_ENDPOINT=https://s3.livops.app
S3_REGION=uz-tas
S3_BUCKET=shop-production-files
S3_ACCESS_KEY=...
S3_SECRET_KEY=...
S3_FORCE_PATH_STYLE=true
AWS_ENDPOINT_URL_S3=https://s3.livops.app
AWS_REGION=uz-tas
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
```

Additional buckets get a prefix with the service name (for example `S3_STORAGE_2_BUCKET`) and don't get `AWS_*`.

URLs are path-style: `https://s3.livops.app/<bucket>/<file>`.

```python
import os, boto3
s3 = boto3.client('s3', endpoint_url=os.environ['S3_ENDPOINT'])
s3.upload_file('report.pdf', os.environ['S3_BUCKET'], 'reports/report.pdf')
```

## Public and private

- A storage bucket is **private by default**: files are accessed with keys or a temporary signed link (presigned URL).
- You can make the whole bucket public — a `..._PUBLIC_URL` variable is then added. Making a single folder public isn't supported.
- CORS rules and automatic deletion of old files (after N days, with an optional prefix, 0–3650 days) are configurable.

## Presets when you create one

The add dialog asks two questions; both can be changed later on the bucket's page.

- **What it is for.** *Uploads* (default) — private; your apps' own pages may read and upload from the browser (CORS for the project's addresses). *Site assets* — public at once: every file is served at `..._PUBLIC_URL`, and any site may read it (CORS `*`, GET/HEAD only).
- **Delete old files** — never, or after 1, 7, 30, 90 or 365 days.

On the bucket's page, the CORS form has the same two presets as buttons: **App pages upload** and **Any site reads**. They fill the form; nothing is saved until you add the rule.

A custom domain for a public bucket is not offered yet.

## Sizes and pricing

| Size | Price per month |
| --- | --- |
| 1 GB | Free — one per team |
| 5 GB | 15 credits (15,000 so'm) |
| 25 GB | 49 credits (49,000 so'm) |
| 100 GB | 149 credits (149,000 so'm) |

The current price is shown in the cabinet's add-storage-bucket dialog.
