/api/v1/resources/temp_upload 接口用于将本地文件上传到 OpenViking 的临时存储区。上传成功后返回 temp_file_id,后续可在 /api/v1/resources 等接口中通过该 ID 引用文件,无需重复上传。
临时文件在服务器端保留约 1 小时后自动清理。请在上传后及时调用后续接口完成资源导入。
完成 API 鉴权说明 页面的 API Key 获取后,可调用本接口上传临时文件。
URI | /api/v1/resources/temp_upload | 统一资源标识符 |
|---|---|---|
请求方法 | POST | 客户端对服务器请求的操作类型 |
请求头 | Content-Type: multipart/form-data | 请求消息类型 |
Authorization: Bearer {api_key} | 鉴权 | |
X-OpenViking-Agent: {agent_id} | Agent ID |
本接口使用 multipart/form-data 格式,包含以下表单字段:
参数 | 类型 | 必选 | 默认值 | 备注 |
|---|---|---|---|---|
file | file | 是 | -- | 要上传的文件 |
telemetry | bool | 否 | false | 是否在响应中返回调用统计信息 |
字段 | 参数说明 |
|---|---|
status | 请求状态,成功为 |
result | 成功时返回的数据对象 |
result.temp_file_id | 临时文件 ID,供后续接口的 |
error | 失败时返回的错误对象 |
error.code | 错误码字符串,例如 |
error.message | 可读的错误描述 |
telemetry | 调用统计信息,例如接口耗时(仅当请求参数 |
curl -X POST https://xxx/api/v1/resources/temp_upload \ -H "Authorization: Bearer {api_key}" \ -H "X-OpenViking-Agent: {agent_id}" \ -F "file=@my_document.md"
执行成功返回:
HTTP/1.1 200 OK Content-Type: application/json { "status": "ok", "result": { "temp_file_id": "upload_abc123def456.md" } }
执行失败返回(缺少鉴权):
HTTP/1.1 401 Unauthorized Content-Type: application/json { "status": "error", "error": { "code": "UNAUTHENTICATED", "message": "Missing API Key when resolving identity." } }