Skip to content

获取已上传文件 ​

接口说明 ​

通过 sourceFileId 读取一个已上传 Markdown 文件的处理状态和可用操作。

接口信息 ​

字段值
方法GET
路径/openapi/v2/knowledge-bases/{knowledgeBaseId}/source-files/{sourceFileId}
Operation IDgetKnowledgeBaseSourceFile
鉴权Bearer OpenAPI key

入参 ​

名称位置必填类型示例说明
knowledgeBaseIdpath是stringknowledge-base-11111111-1111-4111-8111-111111111111知识库 API 返回的知识库标识。
sourceFileIdpath是stringsource-file-11111111-1111-4111-8111-111111111111上传接口或已上传文件列表接口返回的文件标识。

请求体 ​

这个接口没有请求体。

请求示例 ​

bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-11111111-1111-4111-8111-111111111111" \
  -H "Authorization: Bearer <openapi-key>"

成功响应 ​

200 ​

返回指定的已上传 Markdown 文件及其当前处理状态。

字段必填类型说明
sourceFile是object已上传 Markdown 文件记录。

成功响应示例 ​

json
{
  "sourceFile": {
    "sourceFileId": "source-file-11111111-1111-4111-8111-111111111111",
    "knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
    "directoryId": "directory-11111111-1111-4111-8111-111111111111",
    "name": "guide.md",
    "relativePath": "handbook/guide.md",
    "generatedPath": "pages/handbook/guide.md",
    "contentType": "text/markdown; charset=utf-8",
    "sizeBytes": 1024,
    "resourceRevision": 1,
    "contentRevision": 1,
    "state": "available",
    "workProgress": {
      "required": 8,
      "completed": 8,
      "activeKinds": [],
      "blockingKind": null,
      "retryingKind": null
    },
    "failure": null,
    "generatedOutputStatus": "current_available",
    "actions": [
      {
        "kind": "open_generated_file",
        "method": "GET",
        "href": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Fhandbook%2Fguide.md",
        "scope": "source_file"
      }
    ],
    "links": {
      "self": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-11111111-1111-4111-8111-111111111111",
      "generatedContent": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Fhandbook%2Fguide.md",
      "search": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/search?query=guide.md"
    },
    "createdAt": "2026-06-17T00:00:00.000Z"
  }
}

错误码 ​

下表列出这个接口已声明的全部错误响应。

HTTP 状态错误码说明
401UNAUTHORIZEDBearer API key 缺失、格式错误、未知、已撤销或已删除。
404NOT_FOUND请求的资源不存在。
429RATE_LIMITED请求超过当前配置的速率限制。
500INTERNAL_ERRORAPI 遇到内部错误。
503DATABASE_REPOSITORY_UNAVAILABLE当前接口所需的数据暂时不可用。

后续操作 ​