Storage

Downloads and sharing

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
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
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
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.

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
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