Storage
S3-compatible buckets and objects with presigned URLs.
Overview
Base path:
/v1/storagePython namespace:
infra.storagetext
# Python
from infrai import infra
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.storageMethods
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
| Name | Type | Required | Description |
|---|---|---|---|
bucket | string | Required | Bucket name. |
vendor | string | Optional | Pin a specific vendor instead of auto-routing. |
region | string | Optional | Storage region. |
acl | "private" | "public" | Optional | Bucket 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
| Name | Type | Required | Description |
|---|---|---|---|
bucket | string | Required | Bucket name. |
key | string | Required | Object key (path) within the bucket. |
method | "GET" | "PUT" | Optional | HTTP method the presigned URL authorizes. |
expires_seconds | number | Optional | Presigned 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
| Name | Type | Required | Description |
|---|---|---|---|
bucket | string | Required | Bucket name. |
key | string | 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"))