跳转到主要内容

在管理后台上传

  1. 登录 /login
  2. 进入 /assets
  3. 点击 Upload
  4. 选择图片并填写可选字段
  5. 提交后查看资产详情页

通过 API 上传

上传接口是:
POST /api/v1/assets
Content-Type: multipart/form-data

表单字段

字段必填说明
file图片文件
description描述,最长 1000 字符
altText替代文本,最长 1000 字符
isPublic是否公开,默认 true
storageProviderProfileId指定使用的存储 profile
runEnrichment是否上传后立即运行 enrichment,默认 true
commitMessage某些 provider(如 GitHub Repo)可用的提交消息

示例

curl -X POST http://localhost:5121/api/v1/assets \
  -H "Authorization: Bearer <JWT_OR_API_KEY>" \
  -F "file=@kitten.png" \
  -F "description=A fluffy orange kitten" \
  -F "altText=Orange cat looking at camera" \
  -F "isPublic=true" \
  -F "runEnrichment=true"

响应

成功时返回 202 Accepted,并带 data 包装:
{
  "data": {
    "id": "01956f8d-88e4-7c6a-a8f1-5f235293db7a",
    "type": "image",
    "status": "ready",
    "contentType": "image/png",
    "storageProvider": "local",
    "isPublic": true
  }
}

文件校验规则

  • 文件不能为空
  • 文件大小不能超过后端配置的 maxUploadSizeBytes
  • 类型必须在允许的内容类型列表中
  • descriptionaltText 最长 1000 字符

公开与私有

  • isPublic=true 的资产会进入 /gallery
  • isPublic=false 的资产不会出现在公开接口中
  • 私有资产内容需要通过受保护的 /api/v1/assets/{id}/content 访问