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 the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through X-Workspace-ID Header.

  • $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

file_id

string

Yes

File ID, cannot be empty.

volume_id

string

No

Volume ID.

as_zip

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

200.

Content-Type

File MIME type; application/octet-stream when not provided.

Content-Disposition

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

400

ErrParamInvalid

file_id is empty or the request body is invalid.

Pass in a valid file ID.

403

ErrForbidden

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.

404

ErrNotFound

File does not exist.

Check file ID.

500

ErrServer

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.

Last updated on