# Downloads and sharing

Source: https://cubibase.com/docs/storage/downloads

Also available: [Markdown version](https://cubibase.com/docs/storage/downloads.md) · [llms.txt](https://cubibase.com/llms.txt) · [full site content](https://cubibase.com/llms-full.txt)

Every download streams through the engine and is metered byte-accurately against the account’s monthly bandwidth. Public URLs, authorized reads, and signed links all use the same metered path.

## Public files

Objects in public buckets are readable by logical path with only the publishable key. The route is stable and safe to embed in `<img>` tags or share. Private buckets return `404` on this route — they look absent, not forbidden.

**Public read**

```http
GET https://example-project.api.cubibase.com/storage/v1/public/avatars/images/mika.png
apikey: cb_pub_EXAMPLE_ONLY
```

## Private files

Read private objects by id with an end-user JWT or a secret API key. `GET /storage/v1/objects/{id}` returns metadata only; the bytes come from `/content`.

**Authorized read**

```http
GET https://example-project.api.cubibase.com/storage/v1/objects/<OBJECT_ID>/content
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT_OR_SECRET_KEY>
```

## Signed download links

To share a private file without sharing credentials, sign it. The token is scoped to exactly one object, expires after a short deployment-configured lifetime (5 minutes by default), and cannot open any other object. Anyone with the link can read that one file until expiry — and the download counts against bandwidth like any other.

**Sign an object**

```http
POST https://example-project.api.cubibase.com/storage/v1/objects/<OBJECT_ID>/sign
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <SECRET_API_KEY>
Content-Type: application/json

{}
```

The response’s `url` is the download URL with the token attached: `/storage/v1/objects/{id}/content?token=…`. Expired or tampered tokens are rejected with `401`.

## Ranges, cancellation, and metering

- `Range: bytes=start-end` is supported and returns `206` with a truthful `Content-Range`. Only the requested bytes are billed.
- A canceled download is billed only for the bytes actually delivered; the rest of the reservation is refunded.
- If the remaining monthly budget is smaller than the file, the engine delivers a partial `206` response capped at the budget, then refuses further downloads with `402`.
- There are no presigned S3 GET URLs anywhere in the platform: every billable byte passes the meter.

> **note**: Engine-proxied delivery is the current design so quota enforcement is real-time. A CDN/edge delivery path that preserves the same accounting is planned future work.

## Deleting objects

Deletion requires write authorization. The engine removes the bytes from S3 first and only then decrements usage and records the deletion event — usage never drops for a file that still exists.

**Delete**

```http
DELETE https://example-project.api.cubibase.com/storage/v1/objects/<OBJECT_ID>
apikey: cb_pub_EXAMPLE_ONLY
Authorization: Bearer <USER_JWT_OR_SECRET_KEY>
```

## Additional resources

- [Quotas and errors](https://cubibase.com/docs/storage/quotas) Bandwidth limits and reset behavior.
- [Storage security](https://cubibase.com/docs/storage/security) Token scoping and isolation.
