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 theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$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 |
|---|---|---|---|
|
string |
Yes |
File 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 |
|
|
File MIME type; |
|
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 |
|---|---|---|---|
|
|
|
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 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.