Download file¶
Get the download address of the temporary file. This interface only returns the download path, not the file content.
POST https://moi.matrixorigin.cn/newmoi/connectors/file/download
Preparation before calling¶
Prepare a personal access token that has access to the target workspace, the target workspace ID, and the temporary file ID.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: The workspace ID of the file to be downloaded, passed through theX-Workspace-IDHeader.$CONN_FILE_ID: Temporary file ID obtained after uploading or previewing, passed throughconn_file_id.$DOWNLOAD_PATH: The relative download path returned by this interface, used for subsequent download file streams.
Request example¶
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\"
}"
Request body¶
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The ID of the temporary file to download. |
Successful response¶
On success, 200 and the relative download path are returned, but the file content is not returned.
{
"code": "OK",
"msg": "OK",
"data": {
"url": "/newmoi/connectors/file/stream?conn_file_id=conn_file_01"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Relative download path, not file content. Use |
Use the returned path to download the file stream and carry the same authentication request header as this interface:
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
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid file identifier",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The JSON request body is invalid; the interface returns this type of error in this status. |
Check the HTTP status and |
|
|
|
Reupload the file, or confirm the temporary file ID. |
|
|
The access token is invalid or has expired. |
Try again after updating the access token. |
|
|
The caller does not have permission to access the temporary file. |
Check workspace ID and access permissions. |
|
|
The service is temporarily unable to generate a download path. |
Keep the desensitization error message and try again. |
Follow-up operations¶
When the temporary file is no longer needed, use conn_file_id to delete the file.