存储
S3 兼容的存储桶与对象,支持预签名 URL。
概览
https://api.infrai.cc/v1/storageAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/storage capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/storage/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"方法
storage.bucket.create
在所选供应商与区域创建对象存储桶。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称。 |
vendor | string | 可选 | 固定使用某个供应商,而非自动路由。 |
region | string | 可选 | 存储区域。 |
acl | "private" | "public" | 可选 | 存储桶访问控制。 |
返回
Bucket { bucket, vendor, region, created_at, acl? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/bucket/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "..."}'storage.bucket.list
列出你的存储桶。
返回
{ items: Bucket[] }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/bucket/list \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.object.presign
为上传或下载对象创建预签名 URL。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称。 |
key | string | 必填 | 桶内的对象 key(路径)。 |
method | "GET" | "PUT" | 可选 | 预签名 URL 授权的 HTTP 方法。 |
expires_seconds | number | 可选 | 预签名 URL 有效时长(秒)。 |
返回
PresignedUrl { url, method, expires_at, headers? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/object/presign/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"bucket_id": "bkt_42", "key": "uploads/photo.jpg", "ttl_seconds": 3600}'storage.object.delete
从存储桶删除对象。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称。 |
key | string | 必填 | 桶内的对象 key(路径)。 |
返回
{ ok: boolean }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/storage/object/delete/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.bucket.get
获取存储桶元信息
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
返回
Bucket { bucket_id, name, vendor, region, acl, created_at, cors_rules, lifecycle_rules }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/bucket/get/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.bucket.delete
删除存储桶
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
BucketDeleteResult { deleted }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/storage/bucket/delete/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.bucket.usage
查询存储桶用量
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
返回
BucketUsageResult { byte_count, object_count, as_of }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/bucket/usage/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.bucket.set_cors
设置存储桶 CORS 规则
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
rules | CorsRule[] | 必填 | CORS 规则列表(允许的来源、方法、头等) |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
Bucket { bucket_id, name, vendor, region, acl, created_at, cors_rules, lifecycle_rules }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/bucket/set_cors/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rules": []}'storage.bucket.set_lifecycle
设置存储桶生命周期规则
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
rules | LifecycleRule[] | 必填 | 生命周期规则列表(前缀、过期天数、分层转换等) |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
Bucket { bucket_id, name, vendor, region, acl, created_at, cors_rules, lifecycle_rules }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/bucket/set_lifecycle/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rules": []}'storage.bucket.set_notification
订阅存储桶对象事件
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
events | string[] | 必填 | 要订阅的事件类型列表(至少一个) |
target | { webhook_id?: string; url?: string } | 必填 | 回调目标:webhook_id(推荐,复用 scheduling.webhook.*)或裸 url |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
BucketSetNotificationResult { subscription_id }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/bucket/set_notification/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"events": [], "target": {}}'storage.object.put
服务端直接写入对象
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
body | bytes | 必填 | 对象字节内容,作为原始请求体上传 |
content_type | string | 可选 | 对象的 MIME 类型 |
metadata | Record<string, string> | 可选 | 任意用户自定义元数据键值对 |
cache_control | string | 可选 | Cache-Control 头 |
storage_class | string | 可选 | 存储类别(默认 standard) |
idempotency_key | string | 可选 | 幂等键;省略时按内容哈希自动派生 |
返回
StorageObject { bucket_id, key, size_bytes, etag, content_type, metadata, created_at, last_modified }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X PUT https://api.infrai.cc/v1/storage/object/put/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'storage.object.get
下载对象内容
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
返回
object bytes (application/octet-stream)示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/object/get/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.object.head
查询对象元信息
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
返回
ObjectHeadResult { found, status, key, size_bytes, etag, content_type, metadata, last_modified }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/object/head/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.object.list
列举存储桶内对象
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
prefix | string | 可选 | 仅列举键以此前缀开头的对象 |
delimiter | string | 可选 | S3 风格的目录分隔符(如 /),将键归并为 common_prefixes |
cursor | string | 可选 | 来自上次 next_cursor 的分页游标 |
limit | number | 可选 | 本次返回的最大条数(1-1000) |
返回
ObjectListResult { items: StorageObject[], next_cursor, common_prefixes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/storage/object/list/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"storage.object.copy
复制对象
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
src_bucket | string | 必填 | 源存储桶名称 |
src_key | string | 必填 | 源对象键 |
dst_bucket | string | 必填 | 目标存储桶名称 |
dst_key | string | 必填 | 目标对象键 |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
StorageObject { bucket_id, key, size_bytes, etag, content_type, metadata, created_at, last_modified }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/object/copy \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"src_bucket": "...", "src_key": "...", "dst_bucket": "...", "dst_key": "..."}'storage.object.delete_batch
批量删除对象
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
keys | string[] | 必填 | 要删除的对象键列表(1-1000 个) |
idempotency_key | string | 可选 | 幂等键;省略时按键集合内容哈希自动派生 |
返回
ObjectDeleteBatchResult { deleted, errors }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/object/delete_batch/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"keys": []}'storage.object.set_acl
设置对象访问权限
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
acl | "private" | "public" | 必填 | 访问权限:private 或 public |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
ObjectSetAclResult { acl, public_url }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/object/set_acl/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"acl": "..."}'storage.object.set_metadata
设置对象元数据
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
content_type | string | 可选 | 对象的 MIME 类型 |
cache_control | string | 可选 | Cache-Control 头 |
metadata | Record<string, string> | 可选 | 任意用户自定义元数据键值对 |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
StorageObject { bucket_id, key, size_bytes, etag, content_type, metadata, created_at, last_modified }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/object/set_metadata/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'storage.multipart.create
发起分片上传
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
bucket | string | 必填 | 存储桶名称 |
key | string | 必填 | 对象键(路径) |
content_type | string | 可选 | 对象的 MIME 类型 |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
MultipartUpload { upload_id, bucket_id, key, started_at, part_size_min, part_count_max }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/multipart/create/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "..."}'storage.multipart.presign_part
为分片生成预签名 URL
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
upload_id | string | 必填 | 分片上传 ID |
part_number | number | 必填 | 分片序号(从 1 开始) |
返回
MultipartPresignPartResult { url, method, headers, expires_at }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/multipart/presign_part/UPLOAD_ID/PART_NUMBER \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"upload_id": "...", "part_number": 0}'storage.multipart.upload_part
上传单个分片
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
upload_id | string | 必填 | 分片上传 ID |
part_number | number | 必填 | 分片序号(从 1 开始) |
body | bytes | 必填 | 分片字节内容 |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
MultipartPart { part_number, etag }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X PUT https://api.infrai.cc/v1/storage/multipart/upload_part/UPLOAD_ID/PART_NUMBER \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"upload_id": "...", "part_number": 0}'storage.multipart.complete
完成分片上传
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
upload_id | string | 必填 | 分片上传 ID |
parts | MultipartPart[] | 必填 | 已上传分片列表(每项含 part_number 与 etag,1-10000 个) |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
StorageObject { bucket_id, key, size_bytes, etag, content_type, metadata, created_at, last_modified }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/storage/multipart/complete/UPLOAD_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"parts": []}'storage.multipart.abort
中止分片上传
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
upload_id | string | 必填 | 分片上传 ID |
idempotency_key | string | 可选 | 幂等键;省略时自动派生 |
返回
MultipartAbortResult { aborted }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/storage/multipart/abort/UPLOAD_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
| 能力 | 端点 | 说明 |
|---|---|---|
storage.bucket.create | POST /v1/storage/bucket/create | Create an object storage bucket (idempotent). |
storage.bucket.delete | DELETE /v1/storage/bucket/delete/{bucket} | Delete an object storage bucket (idempotent). |
storage.bucket.get | GET /v1/storage/bucket/get/{bucket} | Retrieve a bucket's metadata (provider, region, ACL, CORS, and lifecycle rules). |
storage.bucket.list | GET /v1/storage/bucket/list | List the account's object storage buckets. |
storage.bucket.set_cors | POST /v1/storage/bucket/set_cors/{bucket} | Set CORS rules on a bucket, a prerequisite for browser direct uploads; returns the updated bucket. |
storage.bucket.set_lifecycle | POST /v1/storage/bucket/set_lifecycle/{bucket} | Set lifecycle rules on a bucket for automatic expiration and cold-storage tiering. |
storage.bucket.set_notification | POST /v1/storage/bucket/set_notification/{bucket} | Subscribe object events to a callback (webhook_id or url); returns a subscription ID, delivered via account.webhooks (the single global webhook). |
storage.bucket.usage | GET /v1/storage/bucket/usage/{bucket} | Query a bucket's usage statistics: object count, bytes stored, and measurement timestamp. |
storage.multipart.abort | DELETE /v1/storage/multipart/abort/{upload_id} | Abort a multipart upload and clean up uploaded parts (idempotent). |
storage.multipart.complete | POST /v1/storage/multipart/complete/{upload_id} | Complete a multipart upload, assembling parts into the final StorageObject. |
storage.multipart.create | POST /v1/storage/multipart/create/{bucket} | Initiate a multipart upload, returning an upload_id and part size/count limits. |
storage.multipart.presign_part | POST /v1/storage/multipart/presign_part/{upload_id}/{part_number} | Generate a presigned upload URL for a single part. |
storage.multipart.upload_part | PUT /v1/storage/multipart/upload_part/{upload_id}/{part_number} | Upload the bytes of a single part, returning that part's etag. |
storage.object.copy | POST /v1/storage/object/copy | Copy an object within or across buckets and providers (server-side read/write bridging). |
storage.object.delete | DELETE /v1/storage/object/delete/{bucket}/{key} | Delete a storage object (idempotent). |
storage.object.delete_batch | POST /v1/storage/object/delete_batch/{bucket} | Delete up to 1000 objects in a single call, with partial-success semantics. |
storage.object.get | GET /v1/storage/object/get/{bucket}/{key} | Download an object's contents, returning the raw byte stream. |
storage.object.head | GET /v1/storage/object/head/{bucket}/{key} | Fetch an object's existence and metadata (size, etag, content_type, metadata) without the body. |
storage.object.list | GET /v1/storage/object/list/{bucket} | List objects in a bucket, supporting prefix, delimiter, and cursor pagination. |
storage.object.presign | POST /v1/storage/object/presign/{bucket}/{key} | Generate a presigned URL for direct client upload or download of an object (idempotent). |
storage.object.put | PUT /v1/storage/object/put/{bucket}/{key} | Upload an object server-side, with raw bytes as the request body plus optional content_type/metadata. |
storage.object.set_acl | POST /v1/storage/object/set_acl/{bucket}/{key} | Toggle an object's public/private access, returning the new ACL and public URL. |
storage.object.set_metadata | POST /v1/storage/object/set_metadata/{bucket}/{key} | Update a stored object's content-type, cache-control, and custom metadata. |
完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) storage.bucket.create
curl -X POST https://api.infrai.cc/v1/storage/bucket/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "..."}'
# 3) storage.bucket.list
curl -X GET https://api.infrai.cc/v1/storage/bucket/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 4) storage.object.presign
curl -X POST https://api.infrai.cc/v1/storage/object/presign/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"bucket_id": "bkt_42", "key": "uploads/photo.jpg", "ttl_seconds": 3600}'
# 5) storage.object.delete
curl -X DELETE https://api.infrai.cc/v1/storage/object/delete/BUCKET/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) storage.bucket.get
curl -X GET https://api.infrai.cc/v1/storage/bucket/get/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) storage.bucket.delete
curl -X DELETE https://api.infrai.cc/v1/storage/bucket/delete/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) storage.bucket.usage
curl -X GET https://api.infrai.cc/v1/storage/bucket/usage/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 9) storage.bucket.set_cors
curl -X POST https://api.infrai.cc/v1/storage/bucket/set_cors/BUCKET \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rules": []}'