clouddisk-project/architecture/api-documentation.md

120 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# API 文档
## 认证接口
### POST /api/auth/register
注册新用户
**请求体:**
```json
{
"username": "string",
"password": "string",
"email": "string"
}
```
**响应:**
```json
{
"token": "string",
"userId": number
}
```
### POST /api/auth/login
用户登录
**请求体:**
```json
{
"username": "string",
"password": "string"
}
```
**响应:**
```json
{
"token": "string",
"user": {
"id": number,
"username": "string",
"email": "string",
"storageUsed": number,
"storageLimit": number
}
}
```
## 文件接口
### GET /api/files
获取文件列表
**查询参数:**
- `parentId`: 文件夹ID可选
**响应:**
```json
{
"files": [
{
"id": 1,
"name": "document.pdf",
"type": "pdf",
"size": 1024000,
"is_folder": false,
"updated_at": "2026-03-10T00:00:00Z"
}
]
}
```
### POST /api/files/upload
上传文件
**请求体:** multipart/form-data
**响应:**
```json
{
"success": true,
"fileId": 1,
"filename": "document.pdf"
}
```
### DELETE /api/files/:id
删除文件
**响应:**
```json
{
"success": true
}
```
## 分享接口
### POST /api/share
创建分享链接
**请求体:**
```json
{
"fileId": 1,
"password": "optional",
"expiresIn": 86400
}
```
**响应:**
```json
{
"success": true,
"shareToken": "abc123",
"shareUrl": "/share/abc123"
}
```