Preview file

Get a preview of the file. Office documents are converted to PDF, ZIP to Markdown with inline images, and other files are returned to raw bytes.

HTTP
POST $CLOUDSIGMA_API_BASE/catalog/file/preview_stream

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First query the file list to obtain the target file ID. Prepare the personal access token, target workspace ID, and file ID that can access the target workspace. The caller requires read access to the root volume.

The file must be mounted and the root volume to which it belongs can be determined. Files that are not mounted or belong to multiple root volumes may not be downloaded. Passing in volume_id also cannot bypass this restriction.

Request body

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/file/preview_stream" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "volume_id": "'"$VOLUME_ID"'",
    "file_id": "'"$FILE_ID"'"
  }'

Field

Type

Required

Description

file_id

string

Yes

File ID.

volume_id

string

No

Currently does not participate in this interface processing. Permissions are verified against the actual root volume corresponding to file_id.

Successful response

HTTP
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: inline 或 attachment

[文件内容]

Field

Type

Description

HTTP 状态码

HTTP status

200。

Content-Type

HTTP Header

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

Content-Disposition

HTTP Header

The response contains the attachment filename, and the browser may download the file directly.

响应体

binary

File binary content.

Error response

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

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

Field

Type

Description

code

string

error code.

msg

string

error message.

Last updated on