datai/docs/archive/api-docs/file/FileController/0001-client-list.md

139 lines
2.7 KiB
Markdown
Raw Normal View History

# 获取所有可用存储渠道及其client列表
## 接口信息
- **接口名称**: 获取所有可用存储渠道及其client列表
- **接口路径**: /file/client-list
- **请求方法**: GET
- **模块归属**: file
- **版本号**: v1.0.0
- **创建日期**: 2026-01-18
- **最后更新**: 2026-01-18
## 功能描述
获取系统中所有可用的存储渠道及其对应的客户端列表,用于前端展示可用的存储选项。
## 请求参数
## 响应数据
### 成功响应
**HTTP 状态码**: 200 OK
```json
{
"code": 200,
"message": "操作成功",
"data": {
"storageTypes": [
{
"storageType": "local",
"clients": [
{
"name": "local",
"displayName": "本地存储"
}
]
},
{
"storageType": "minio",
"clients": [
{
"name": "minio-primary",
"displayName": "MinIO主存储"
}
]
},
{
"storageType": "aliyun-oss",
"clients": [
{
"name": "aliyun-oss-primary",
"displayName": "阿里云OSS主存储"
}
]
}
]
}
}
```
| 字段名 | 类型 | 描述 | 示例 |
|--------|------|------|------|
| storageTypes | Array | 存储类型列表 | - |
| storageType | String | 存储类型标识 | local, minio, aliyun-oss |
| clients | Array | 该存储类型下的客户端列表 | - |
| name | String | 客户端名称 | minio-primary |
| displayName | String | 客户端显示名称 | MinIO主存储 |
### 失败响应
**HTTP 状态码**: 500 Internal Server Error
```json
{
"code": 500,
"message": "获取存储渠道失败",
"data": null
}
```
## 接口示例
### 请求示例
```bash
curl -X GET "http://localhost:8080/file/client-list" \
-H "Authorization: Bearer [token]"
```
### 响应示例
**成功**:
```json
{
"code": 200,
"message": "操作成功",
"data": {
"storageTypes": [
{
"storageType": "local",
"clients": [
{
"name": "local",
"displayName": "本地存储"
}
]
}
]
}
}
```
## 错误处理
- 系统异常时返回 500 错误码
- 错误信息包含详细的异常描述
## 注意事项
- 该接口不需要任何参数
- 返回的存储渠道列表基于系统配置
- 前端可以使用返回的数据构建存储选择器
## 相关接口
- [统一上传接口](./0002-upload.md) - 使用存储渠道上传文件
- [统一下载接口](./0003-download.md) - 使用存储渠道下载文件
## 实现细节
- 使用 `StorageUtils.getClientList()` 获取存储渠道列表
- 存储渠道配置在系统配置文件中定义
- 支持多种存储类型local、minio、aliyun-oss 等