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.
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¶
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 |
|---|---|---|---|
|
string |
Yes |
File 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/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: inline 或 attachment
[文件内容]
Field |
Type |
Description |
|---|---|---|
|
HTTP status |
|
|
HTTP Header |
File MIME type. |
|
HTTP Header |
The response contains the |
|
binary |
File binary content. |
Error response¶
When the preview fails before starting, the response uses the JSON error response format:
{
"code": "ErrNotFound",
"msg": "对象不存在"
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
error message. |