Skip to content

Storage

S3-compatible buckets and objects with presigned URLs.

Overview

Base path: /v1/storage
Python namespace: infra.storage
text
# Python
from infrai import infra

# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.storage

Methods

storage.bucket.create

POST /v1/storage/buckets

Create an object-storage bucket on a chosen vendor and region.

Python

python
infra.storage.bucket.create(bucket=..., vendor=None, region=None, acl=None)

TypeScript

typescript
client.storage.bucket.create(opts): Promise<Bucket>

Parameters

NameTypeRequiredDescription
bucketstring
Required
Bucket name.
vendorstringOptionalPin a specific vendor instead of auto-routing.
regionstringOptionalStorage region.
acl"private" | "public"OptionalBucket access control.

Returns

Bucket { bucket, vendor, region, created_at, acl? }

Example

一次性前置(每个范例都假定已完成):

bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...
python
from infrai import infra

b = infra.storage.bucket.create(bucket="user-uploads", acl="private")
print("bucket:", b.get("bucket"), "| vendor:", b.get("vendor"))

storage.bucket.list

GET /v1/storage/buckets

List your buckets.

Python

python
infra.storage.bucket.list()

TypeScript

typescript
client.storage.bucket.list(): Promise<{ items }>

Returns

{ items: Bucket[] }

Example

一次性前置(每个范例都假定已完成):

bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...
python
from infrai import infra

for b in infra.storage.bucket.list().get("items", []):
    print(b.get("bucket"), b.get("region"))

storage.object.presign

POST /v1/storage/buckets/{bucket}/objects/{key}/presign

Create a presigned URL for uploading or downloading an object.

Python

python
infra.storage.object.presign(bucket=..., key=..., method="PUT", expires_seconds=None)

TypeScript

typescript
client.storage.object.presign(opts): Promise<PresignedUrl>

Parameters

NameTypeRequiredDescription
bucketstring
Required
Bucket name.
keystring
Required
Object key (path) within the bucket.
method"GET" | "PUT"OptionalHTTP method the presigned URL authorizes.
expires_secondsnumberOptionalPresigned URL lifetime in seconds.

Returns

PresignedUrl { url, method, expires_at, headers? }

Example

一次性前置(每个范例都假定已完成):

bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...
python
from infrai import infra

# Presign a PUT, then upload bytes directly to the object store.
put = infra.storage.object.presign(
    bucket="demo",
    key="uploads/hello.txt",
    method="PUT",
    expires_seconds=600,
)
print("upload url:", put.get("url"))

storage.object.delete

DELETE /v1/storage/buckets/{bucket}/objects/{key}

Delete an object from a bucket.

Python

python
infra.storage.object.delete(bucket=..., key=...)

TypeScript

typescript
client.storage.object.delete(opts): Promise<{ ok }>

Parameters

NameTypeRequiredDescription
bucketstring
Required
Bucket name.
keystring
Required
Object key (path) within the bucket.

Returns

{ ok: boolean }

Example

一次性前置(每个范例都假定已完成):

bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...
python
from infrai import infra

res = infra.storage.object.delete(bucket="user-uploads", key="uploads/old.txt")
print("deleted:", res.get("ok"))