获取上传会话
接口说明
读取上传进度,以及继续上传所需的下一页文件记录。
接口信息
| 字段 | 值 |
|---|---|
| 方法 | GET |
| 路径 | /openapi/v2/knowledge-bases/{knowledgeBaseId}/upload-sessions/{uploadSessionId} |
| Operation ID | getUploadSession |
| 鉴权 | Bearer OpenAPI key |
入参
| 名称 | 位置 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|---|
knowledgeBaseId | path | 是 | string | knowledge-base-11111111-1111-4111-8111-111111111111 | 知识库 API 返回的知识库标识。 |
uploadSessionId | path | 是 | string | upload-11111111-1111-4111-8111-111111111111 | 创建上传会话后返回的会话标识。 |
limit | query | 否 | integer | 50 | 最多返回的记录数量。部署环境可能采用更低的上限。 |
cursor | query | 否 | string | cursor_123 | 当前接口返回的下一页分页标记。 |
transferState | query | 否 | missing | uploaded | missing | 可选的上传项传输状态筛选条件。 |
请求体
这个接口没有请求体。
请求示例
bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/upload-sessions/upload-11111111-1111-4111-8111-111111111111?limit=50" \
-H "Authorization: Bearer <openapi-key>"成功响应
200
返回当前上传会话及所请求的文件记录分页。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
session | 是 | object | 当前上传会话记录。 |
entries | 是 | allOf(Page) | 请求返回的上传文件记录,以及读取下一页所需的分页标记。 |
成功响应示例
json
{
"session": {
"id": "upload-11111111-1111-4111-8111-111111111111",
"operationId": "upload-operation-11111111-1111-4111-8111-111111111111",
"knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
"state": "completed",
"declaredFileCount": 1,
"declaredByteCount": 37,
"counts": {
"selected": 1,
"uploadRequired": 1,
"skippedExisting": 0,
"waitingReservation": 0,
"rejectedDeleting": 0,
"uploaded": 1,
"finalized": 1
},
"errorCode": null,
"expiresAt": "2026-06-18T00:00:00.000Z",
"completedAt": "2026-06-17T00:00:00.000Z",
"createdAt": "2026-06-17T00:00:00.000Z",
"updatedAt": "2026-06-17T00:00:00.000Z",
"actions": {
"operation": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/operations/upload-operation-11111111-1111-4111-8111-111111111111"
}
},
"entries": {
"items": [
{
"id": "upload-entry-11111111-1111-4111-8111-111111111111",
"relativePath": "handbook/onboarding/guide.md",
"directoryPath": "handbook/onboarding",
"name": "guide.md",
"declaredSize": 37,
"receivedSize": 37,
"disposition": "upload_required",
"transferState": "uploaded",
"sourceFileId": "source-file-11111111-1111-4111-8111-111111111111",
"existingResourceRevision": null
}
],
"nextCursor": null
}
}错误码
下表列出这个接口已声明的全部错误响应。
| HTTP 状态 | 错误码 | 说明 |
|---|---|---|
| 401 | UNAUTHORIZED | Bearer API key 缺失、格式错误、未知、已撤销或已删除。 |
| 404 | NOT_FOUND | 请求的资源不存在。 |
| 422 | VALIDATION_ERROR | 请求未通过校验。 |
| 429 | RATE_LIMITED | 请求超过当前配置的速率限制。 |
| 500 | INTERNAL_ERROR | API 遇到内部错误。 |
| 503 | DATABASE_REPOSITORY_UNAVAILABLE | 当前接口所需的数据暂时不可用。 |