Skip to main content
数据导入

申请上传租约

上传文件到数据中心的第一步,返回 OSS 预签名 URL 和租约 ID

POST
/api/v1/connector/dash/applyFileUploadLease
cURL
curl -X POST "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/connector/dash/applyFileUploadLease" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "category": "cate_abc123",
    "fileName": "product-guide.pdf",
    "sizeBytes": "1048576",
    "contentMd5": "d41d8cd98f00b204e9800998ecf8427e"
  }'
{
  "code": "Success",
  "message": "",
  "messageUnmodified": false,
  "requestId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "data": {
    "type": "OSS.PreSignedUrl",
    "param": {
      "url": "https://oss-example.aliyuncs.com/...",
      "method": "PUT",
      "headers": {
        "x-bailian-extra": "MTkxMDA3MzE0NjA0NDgzNA==",
        "Content-Type": "text/plain"
      }
    },
    "leaseId": "82845f78ab0343ada293c9595ed93dbf.1782191906659"
  },
  "status": 200
}
文件上传分为三步:
  1. 申请租约(本接口)— 获取 OSS 预签名 URL 和 leaseId
  2. PUT 上传到 OSS — 使用返回的 param.urlparam.headers 通过 HTTP PUT 上传文件二进制内容
  3. 注册文件addFile)— 使用 leaseId 将文件注册到数据中心
请注意 sizeBytes 必须以字符串格式传入(如 "1048576"),不能传数字。

Authorizations

string
header
required

DashScope API Key,在控制台 API Key 页面(https://rag.console.aliyun.com/settings/apikey)获取。

Body

application/json
string
required

类目 ID(注意:此字段名为 category,不是 categoryId),通过 listCategory 获取。

string
required

文件名称,包含扩展名。

string
required

文件大小(字节),以字符串格式传入。

x >= 1
string
required

文件内容的 MD5 值(Base64 编码)。

length: 1–64

Response

200-application/json
string

响应码,成功时为 Success

integer

HTTP 状态码。

string

请求唯一标识,排查问题时请提供此 ID。

object