调用条件、权限、请求字段、响应字段与错误处理。
请求与权限
POSThttps://openapi.qwenwork.ai/v1/drive/direct-uploads
鉴权:Authorization: Bearer <access_token>;使用用户 OAuth 授权获得的访问令牌。
所需业务 Scope:drive.upload.write
契约声明的授权方式:组织授权(organization)、个人授权(personal)
Scope 需由平台为应用开通;用户须有相应业务权限,目标资源须在其可访问范围内。个人/组织方式是否为该应用开放,以控制台实际配置为准。
功能与限制
创建或恢复直传上传。签名 URL 具有有效期,不记录或分享,不携带平台 Token 访问 OSS。上游继续校验用户和 Scope。请求头参数
| 参数 | 类型 | 必填 | 说明及约束 |
|---|---|---|---|
Idempotency-Key | string | 是 | 同一逻辑上传重试时复用;不能用于不同参数。 最短长度:1 最长长度:128 匹配规则:"^[!-~]+$" |
请求体
请求体必填。application/json
子字段的“必填”在所属对象存在时生效;联合类型的各分支分别列出,不代表同时要求所有分支字段。| 字段 | 类型 | 必填 | 说明及约束 |
|---|---|---|---|
mime_type | string | 否 | 最长长度:255 |
path | string | 是 | 最短长度:1 匹配规则:"^/" |
size | integer | 是 | 最小值(含):1 |
upload_mode | string | 是 | 可选值:["single", "multipart"] |
成功响应
保持各业务接口原始响应结构,不统一添加code/msg/data 包装。
HTTP 200
幂等重放 响应类型:application/json
| 字段 | 类型 | 必含 | 说明及约束 |
|---|---|---|---|
session_id | string | 是 | — |
status | string | 是 | — |
upload | object | 否 | — |
upload | object | 否 | 恰好满足一种:分支 1 — |
upload.headers | object | 是 | 恰好满足一种:分支 1 额外字段:"受 Schema 约束,见完整契约" |
upload.url | string | 是 | 恰好满足一种:分支 1 — |
upload | object | 否 | 恰好满足一种:分支 2 — |
upload.headers | object | 是 | 恰好满足一种:分支 2 额外字段:"受 Schema 约束,见完整契约" |
upload.part_size | integer | 是 | 恰好满足一种:分支 2 — |
upload.parts | array | 是 | 恰好满足一种:分支 2 — |
upload.parts[] | object | 否 | 恰好满足一种:分支 2 — |
upload.parts[].part_number | integer | 是 | 恰好满足一种:分支 2 — |
upload.parts[].url | string | 是 | 恰好满足一种:分支 2 — |
upload_mode | string | 是 | — |
HTTP 201
创建成功 响应类型:application/json
字段与前述 HTTP 200 相同。
错误响应
| HTTP | 说明及处理 |
|---|---|
400 | 业务或网关错误 |
401 | 业务或网关错误 |
403 | 业务或网关错误 |
404 | 业务或网关错误 |
409 | 业务或网关错误 |
410 | 业务或网关错误 |
413 | 业务或网关错误 |
429 | 业务或网关错误 |
500 | 业务或网关错误 |
502 | 业务或网关错误 |
503 | 业务或网关错误 |
504 | 业务或网关错误 |
完整字段契约
下方 JSON 包含本接口完整请求、响应、错误 Schema、嵌套约束和公开扩展定义,可复制用于核对。未声明的成功示例不作推测。展开完整接口 OpenAPI JSON
展开完整接口 OpenAPI JSON
Copy
{
"components": {
"schemas": {
"Error": {
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object"
},
"Upload": {
"properties": {
"session_id": {
"type": "string"
},
"status": {
"type": "string"
},
"upload": {
"oneOf": [
{
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"url": {
"type": "string"
}
},
"required": [
"url",
"headers"
],
"type": "object"
},
{
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"part_size": {
"type": "integer"
},
"parts": {
"items": {
"properties": {
"part_number": {
"type": "integer"
},
"url": {
"type": "string"
}
},
"required": [
"part_number",
"url"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"part_size",
"headers",
"parts"
],
"type": "object"
}
]
},
"upload_mode": {
"type": "string"
}
},
"required": [
"session_id",
"upload_mode",
"status"
],
"type": "object"
}
},
"securitySchemes": {
"OpenPlatformBearer": {
"scheme": "bearer",
"type": "http"
}
}
},
"openapi": "3.1.0",
"paths": {
"/v1/drive/direct-uploads": {
"post": {
"description": "创建或恢复直传上传。签名 URL 具有有效期,不记录或分享,不携带平台 Token 访问 OSS。上游继续校验用户和 Scope。",
"operationId": "drive-post-direct-uploads",
"parameters": [
{
"description": "同一逻辑上传重试时复用;不能用于不同参数。",
"in": "header",
"name": "Idempotency-Key",
"required": true,
"schema": {
"maxLength": 128,
"minLength": 1,
"pattern": "^[!-~]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"mime_type": {
"maxLength": 255,
"type": "string"
},
"path": {
"minLength": 1,
"pattern": "^/",
"type": "string"
},
"size": {
"minimum": 1,
"type": "integer"
},
"upload_mode": {
"enum": [
"single",
"multipart"
],
"type": "string"
}
},
"required": [
"path",
"size",
"upload_mode"
],
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Upload"
}
}
},
"description": "幂等重放",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Upload"
}
}
},
"description": "创建成功",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"400": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"401": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
}
},
"required": [
"code"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"403": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
}
},
"required": [
"code"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"404": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"409": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"410": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"413": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"429": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"500": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"502": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"503": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
}
},
"required": [
"code"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
},
"504": {
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/Error"
},
{
"properties": {
"code": {
"type": "integer"
},
"data": {
"type": "null"
},
"msg": {
"type": "string"
}
},
"required": [
"code",
"msg",
"data"
],
"type": "object"
}
]
}
}
},
"description": "业务或网关错误",
"headers": {
"X-Request-ID": {
"description": "开放平台为每次 HTTP 请求生成的请求 ID,用于日志关联与故障排查;重试生成新的 ID,不是幂等键或分布式 Trace ID。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
},
"X-Trace-ID": {
"description": "开放平台当前请求的 OpenTelemetry TraceID,通过请求日志与 X-Request-ID 关联;采样未保留时可能没有完整链路记录。",
"schema": {
"pattern": "^[0-9a-f]{32}$",
"type": "string"
}
}
}
}
},
"security": [
{
"OpenPlatformBearer": []
}
],
"summary": "创建或恢复直传上传",
"tags": [
"直传上传"
]
}
}
},
"info": {
"title": "创建或恢复直传上传",
"version": "2026-11-24"
},
"servers": [
{
"url": "https://openapi.qwenwork.ai"
}
]
}