Knowledge Sources - Upload File
将文件上传到文件知识源进行处理和索引。
POST {endpoint}/knowledgesources('{sourceName}')/files?api-version=2026-05-01-preview
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
endpoint
|
path | True |
string (uri) |
搜索服务的终结点 URL。 |
|
source
|
path | True |
string |
知识源的名称。 |
|
api-version
|
query | True |
string minLength: 1 |
用于此操作的 API 版本。 |
请求头
Media Types: "application/octet-stream"
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| Content-Disposition | True |
string |
Content-Disposition 头部指定上传文件的文件名。
必须遵循格式: |
| x-ms-client-request-id |
string (uuid) |
请求的不透明、全局唯一的客户端生成的字符串标识符。 |
请求正文
Media Types: "application/octet-stream"
| 名称 | 类型 | 说明 |
|---|---|---|
| file |
string (binary) |
上传文件内容。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 201 Created |
请求已成功,因此创建了一个新资源。 |
|
| Other Status Codes |
未预期的错误响应。 |
安全性
api-key
类型:
apiKey
在:
header
OAuth2Auth
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
作用域
| 名称 | 说明 |
|---|---|
| https://search.azure.com/.default |
示例
SearchServiceUploadKnowledgeSourceFile
示例请求
POST https://previewexampleservice.search.windows.net/knowledgesources('ks-file-test')/files?api-version=2026-05-01-preview
"dGVzdCBmaWxlIGNvbnRlbnQ="
示例响应
{
"fileId": "00000000-0000-0000-0000-000000000001",
"fileName": "example.pdf",
"fileSizeBytes": 12345,
"createdAt": "2026-01-01T00:00:00Z",
"lastUpdatedAt": "2026-01-01T00:00:00Z",
"errorMessage": null
}
定义
| 名称 | 说明 |
|---|---|
|
Error |
资源管理错误附加信息。 |
|
Error |
错误详情 |
|
Error |
所有 Azure 资源管理器 API 的常见错误响应,以返回失败操作的错误详细信息。 (这也遵循 OData 错误响应格式)。 |
|
Knowledge |
上传到文件知识源的文件元数据。 |
ErrorAdditionalInfo
资源管理错误附加信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| info |
附加信息。 |
|
| type |
string |
其他信息类型。 |
ErrorDetail
错误详情
| 名称 | 类型 | 说明 |
|---|---|---|
| additionalInfo |
错误的附加信息。 |
|
| code |
string |
错误代码。 |
| details |
错误详情。 |
|
| message |
string |
错误消息。 |
| target |
string |
错误的目标。 |
ErrorResponse
所有 Azure 资源管理器 API 的常见错误响应,以返回失败操作的错误详细信息。 (这也遵循 OData 错误响应格式)。
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
错误对象。 |
KnowledgeSourceFile
上传到文件知识源的文件元数据。
| 名称 | 类型 | 说明 |
|---|---|---|
| createdAt |
string (date-time) |
文件创建的时间戳。 |
| errorMessage |
string |
如果文件处理失败,则显示错误信息,否则为空。 |
| fileId |
string |
文件的唯一标识符。 |
| fileName |
string |
原始文件名。 |
| fileSizeBytes |
integer (int64) |
文件大小(以字节为单位)。 |
| lastUpdatedAt |
string (date-time) |
文件最后更新的时间戳。 |