feat: batch delete
This commit is contained in:
@@ -48,11 +48,12 @@ curl -F "file=@report.pdf" http://localhost:8080/upload
|
||||
|
||||
| Method | Path | 说明 |
|
||||
|--------|----------------------------|--------------------------------------------|
|
||||
| GET | `/` | Web UI(单 HTML 响应,内联 CSS + JS) |
|
||||
| GET | `/` | Web UI(单 HTML 响应,CSS/JS 经 `/static` 引用) |
|
||||
| POST | `/upload` | 上传文件(`multipart/form-data`,字段名 `file`) |
|
||||
| GET | `/files` | 列出当前未过期文件 |
|
||||
| GET | `/download/:filename` | 下载文件 |
|
||||
| POST | `/download-zip` | 批量下载 (body: `{"files":[...]}`, 最多 100 项) |
|
||||
| POST | `/files-delete` | 批量删除 (body: `{"files":[...]}`, 最多 100 项) |
|
||||
| DELETE | `/files/:filename` | 删除文件 |
|
||||
|
||||
---
|
||||
@@ -61,29 +62,31 @@ curl -F "file=@report.pdf" http://localhost:8080/upload
|
||||
|
||||
```text
|
||||
tmp-upload/
|
||||
├── main.go # 入口、配置、路由注册 (61 行)
|
||||
├── embed.go # //go:embed + init() 拼接 (38 行)
|
||||
├── main.go # 入口、配置、路由注册 (72 行)
|
||||
├── embed.go # //go:embed + fs.Sub 静态资源 (26 行)
|
||||
├── audit.go # 审计日志子系统 (102 行)
|
||||
├── quota.go # 配额管理 + formatSize (112 行)
|
||||
├── handlers.go # HTTP handlers + DTOs (440 行)
|
||||
├── handlers.go # HTTP handlers + DTOs (308 行)
|
||||
├── batch.go # 批量下载 / 批量删除 handlers (248 行)
|
||||
├── cleaner.go # TTL 过期清理 (57 行)
|
||||
├── audit_test.go # audit 单元测试
|
||||
├── security_test.sh # HTTP 端到端测试
|
||||
├── go.mod / go.sum
|
||||
└── static/
|
||||
├── index.html.tpl # HTML 骨架 (含 /*EMBED_CSS*/、/*EMBED_JS*/ 占位符)
|
||||
├── app.css # CSS (357 行)
|
||||
├── app.js # JS — 主程序 (441 行)
|
||||
├── index.html.tpl # HTML 骨架 (经 /static 引用 CSS/JS, 含批量删除按钮)
|
||||
├── app.css # CSS (359 行)
|
||||
├── app.js # JS — 主程序 (443 行)
|
||||
├── helpers.js # JS — 纯函数 + 倒计时 (58 行)
|
||||
└── batch.js # JS — 批量选择 / 批量下载 (87 行)
|
||||
└── batch.js # JS — 批量选择 / 批量下载 / 批量删除 (119 行)
|
||||
```
|
||||
|
||||
### 单文件部署说明
|
||||
|
||||
`embed.go` 用 `//go:embed` 把三个静态文件全部编入二进制,
|
||||
在 `init()` 中用 `strings.Replace` 把 CSS/JS 拼到 HTML 骨架里生成 `pageHTML`。
|
||||
浏览器访问 `/` 拿到的是**一个**完整 HTML 响应(HTML+CSS+JS 全部内联),
|
||||
不产生额外的 `<link>` / `<script src=>` 请求。
|
||||
`embed.go` 用 `//go:embed` 把 `static/` 下的 CSS/JS 编入二进制,
|
||||
在 `init()` 中用 `fs.Sub` 切出 `static/` 子文件系统供 `/static` 路由对外提供;
|
||||
HTML 骨架 `index.html.tpl` 单独 embed,`GET /` 直接返回。
|
||||
浏览器加载的是拆分请求(HTML + `<link>` CSS + `<script>` JS),
|
||||
但所有资源仍编译进单个二进制,部署依旧单文件,无需运行时外部文件。
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user