<span id="预览工作区文件内容"></span>

# Preview workspace file content

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Read browser preview content, converting Office documents to PDF when needed.

```text
GET https://api.moi.matrixorigin.cn/v5/workspaces/{id}/files/{file_id}/preview
```

<span id="调用前准备"></span>

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`; use the corresponding product API URL for a dedicated deployment.

Prepare a personal access token for the target workspace. WORKSPACE_ID must match the path workspace; FILE_ID comes from actual file results. BASE_URL includes the product prefix in the same environment. Example files/IDs are placeholders.

<span id="请求参数"></span>

## Request parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --fail-with-body -sS -X GET "$BASE_URL/workspaces/$WORKSPACE_ID/files/$FILE_ID/preview" \
  -H "X-API-Key: $MOI_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -o "$OUTPUT_FILE"
```

:::::
:::::{tab-item} Parameters

No business request body. Set the path workspace and file ID to actual targets.

Original and converted content both have a 100 MiB preview limit. Office previews require a configured converter. HTML/HTM/SVG return as attachments; other applicable formats may render inline. Preview bytes may differ from the original download.

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```text
sample
```

:::::
:::::{tab-item} Fields

The response is a byte stream. Consume and close it, and check read/exit status before using the file. Failure after the response starts may interrupt the connection.

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error responses

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": 2,
  "message": "示例错误信息"
}
```

:::::
:::::{tab-item} Fields

Unsupported formats return 400/2, preview size overflow 413/14, missing files 404/3, denied permissions 403/5, unavailable authorization 503/15, and conversion failures may return 500/1.

:::::
::::::
:::::::
