changelog: 管理端文件预览接口更新(返回原始二进制流)
preview-by-url 现在返回原始文件流(与/{fileId}/preview一致),前端用iframe直接显示。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
这个提交包含在:
父节点
2097b74bd0
当前提交
70cf4ac59b
@ -0,0 +1,37 @@
|
||||
# 管理端文件预览接口(更新)
|
||||
|
||||
**日期**: 2026-03-23
|
||||
**类型**: 接口更新
|
||||
|
||||
---
|
||||
|
||||
## 接口
|
||||
|
||||
```
|
||||
GET /admin/file/preview-by-url?url=编码后的完整OSS_URL
|
||||
```
|
||||
|
||||
**无需登录,无需 token。**
|
||||
|
||||
## 返回内容
|
||||
|
||||
直接返回**原始文件二进制流**(与 `/{fileId}/preview` 一致):
|
||||
- PDF → Content-Type: application/pdf
|
||||
- 图片 → Content-Type: image/jpeg 等
|
||||
- 其他 → 对应 MIME 类型
|
||||
|
||||
## 前端使用
|
||||
|
||||
```javascript
|
||||
// iframe 嵌入(推荐,PDF和图片都能直接显示)
|
||||
<iframe :src="`/api/admin/file/preview-by-url?url=${encodeURIComponent(ossUrl)}`"
|
||||
width="100%" height="600px" />
|
||||
|
||||
// 或新窗口打开
|
||||
window.open(`/api/admin/file/preview-by-url?url=${encodeURIComponent(ossUrl)}`)
|
||||
|
||||
// 或 img 标签(仅图片)
|
||||
<img :src="`/api/admin/file/preview-by-url?url=${encodeURIComponent(ossUrl)}`" />
|
||||
```
|
||||
|
||||
**注意**:url 参数必须 `encodeURIComponent` 编码。
|
||||
正在加载...
x
在新工单中引用
屏蔽一个用户