Preview file

Preview files as inline content.

POST https://moi.matrixorigin.cn/newmoi/catalog/file/preview_stream

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 preview.

  • $VOLUME_ID: The data volume ID where the target file is located.

The caller requires read access to the root volume.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/preview_stream" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "volume_id": "'"$VOLUME_ID"'",
    "file_id": "'"$FILE_ID"'"
  }'

Request body

Parameter

Type

Required

Description

file_id

string

Yes

File ID.

volume_id

string

Yes

The ID of the data volume where the file is located.

Successful response

On success, 200 is returned, the response body is the file content, and Content-Disposition: inline is used. The caller requires read access to the root volume.

The response is not a JSON envelope. Content type of the service settings file; application/octet-stream is used when not provided. If a filename is available, the response header also contains Content-Disposition: inline.

Response items

Description

HTTP status code

200.

Content-Type

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

Content-Disposition

Displayed inline when filename is available.

Response body

File binary content.

Error response

When the preview fails before starting, the response uses a JSON error envelope:

{
  "code": "ErrNotFound",
  "msg": "对象不存在",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

ErrParamInvalid

file_id is missing 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 file preview stream.

Record the request time and error message and try again; if it continues to fail, contact support.

Follow-up operations

After completion, Query Catalog details confirms the result.

Last updated on