下载文件¶
获取临时文件的下载地址。该接口只返回下载路径,不返回文件内容。
POST https://moi.matrixorigin.cn/newmoi/connectors/file/download
调用前准备¶
请求体¶
将 $AI_STUDIO_API_KEY、$WORKSPACE_ID 和 $CONN_FILE_ID 替换为实际值。
curl -X POST "https://moi.matrixorigin.cn/newmoi/connectors/file/download" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"conn_file_id\": \"$CONN_FILE_ID\"
}"
参数 |
类型 |
是否必填 |
说明 |
|---|---|---|---|
|
string |
是 |
要下载的临时文件 ID。 |
成功响应¶
{
"code": "OK",
"msg": "OK",
"data": {
"url": "/newmoi/connectors/file/stream?conn_file_id=conn_file_01"
}
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
成功时为 |
|
string |
成功时为 |
|
string |
相对文件流下载路径。 |
使用 data.url 与 https://moi.matrixorigin.cn 组成完整下载地址,并携带相同认证请求头请求文件内容:
curl -L "https://moi.matrixorigin.cn$DOWNLOAD_PATH" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-o ./downloaded-file
将 $DOWNLOAD_PATH 替换为响应中的 data.url。命令将文件内容保存为本地的 downloaded-file。
错误响应¶
{
"code": "ErrParamInvalid",
"msg": "invalid file identifier",
"data": null
}
字段 |
类型 |
说明 |
|---|---|---|
|
string |
错误代码。 |
|
string |
错误信息。 |
|
null |
错误响应中为 |
后续操作¶
不再需要临时文件时,删除文件。
最后更新于