Download file¶
Download file contents.
POST https://moi.matrixorigin.cn/newmoi/catalog/file/download
Preparation before calling¶
First query the file list to obtain the target file ID. Prepare the personal access token, target workspace ID, and file ID that have access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$FILE_ID: File ID to download.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/download" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"file_id": "'"$FILE_ID"'"
}' \
-o ./downloaded-file
Request body¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
File ID, cannot be empty. |
|
string |
No |
Volume ID. |
|
boolean |
No |
Whether to download in ZIP format. |
Successful response¶
Returns 200 and the file contents on success. The response body is not in JSON format.
When a filename is available, the response header Content-Disposition specifies the attachment to download and provides the filename. When no content type is provided, Content-Type is application/octet-stream.
Response items |
Description |
|---|---|
HTTP status code |
|
|
File MIME type; |
|
Attachment download when filename is available. |
Response body |
File content. |
Error response¶
When the download fails before it starts, an error message in JSON format is returned:
{
"code": "ErrParamInvalid",
"msg": "file_id 不能为空",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Pass in a valid file ID. |
|
|
The current identity does not have read permission on the root volume to which it belongs. |
Use credentials with read access, or contact your administrator for authorization. |
|
|
File does not exist. |
Check file ID. |
|
|
The service cannot open the download stream. |
Record the request time and error message and try again; if it continues to fail, contact support. |
Follow-up operations¶
If you need to continue management after the download is completed, return to Query Catalog details.