GET
/files/:file_id/preview
GET /v1/files/{file_id}/preview?as_attachment=false
Host: api.dify.ai
Authorization: Bearer {API_KEY}
路径参数
| 参数 | 必须 | 说明 |
|---|---|---|
file_id |
是 | /files/upload 返回的 id |
请求头
| 头部 | 必须 | 说明 |
|---|---|---|
| Authorization | 是 | Bearer {API_KEY} |
| Accept | 否 | 对图片可用 image/* 让浏览器直接显示 |
| 参数 | 类型 | 必须 | 默认值 | 说明 |
|---|---|---|---|---|
as_attachment |
boolean | 否 | false | true 时强制以附件下载;false 时直接在浏览器预览 |
响应头:
| 头部 | 说明 |
|---|---|
| Content-Type | 文件 MIME 类型(如 image/png、application/pdf) |
| Content-Length | 文件大小(字节) |
| Content-Disposition | 当 as_attachment=true 时,值为 attachment |
| Cache-Control | 缓存策略 |
| Accept-Ranges | 对音/视频文件时为 "bytes" |
响应体:文件的二进制内容(非 JSON)