Files
SKYMirror 84df9996cb
CI 测试 / go vet + go test (push) Successful in 49s
26.9:版本号统一 + CI 精简 + 前端产物重建
- 全项目版本号统一:v3.x 迭代号(26.9/26.9/26.9/26.9 及裸 v2/v3)→ 26.9,
  覆盖 Go 注释 / 文档 / openapi.yaml / README×4 / 前端源码(80+ 处)
- v31_test.go 更名 custom_code_test.go;TestV2AccessorDefaults → TestKVAccessorDefaults
- docs/api/00-overview.md 更新日志合并为单条 26.9 条目(修复错位拼接)
- .goreleaser.yaml 头部注释与实际一致(Pro 2.18.1 / GITEA_TOKEN / semver tag 要求)
- CI:release-image.yml → ci.yml,仅保留 vet+test 门禁;
  镜像发布移交 GoReleaser Pro(原 build-push 的 tag 校验与 26.9 版本方案冲突,历史 9 次失败)
- 前端重建:server/web/dist 与 web-embed 同步(docs 文案嵌入更新)
2026-09-08 03:16:51 +08:00

92 lines
3.2 KiB
Markdown
Raw Permalink 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.
# 文本分享
创建纯文本分享,返回取件码。文本大小上限 **222KB**(超限建议改用文件分享);请求体全局上限 1MiB,`Content-Length` >441KB 时读前直接 403。
经审计中间件落库(action=upload)。
## POST /share/text
**请求参数**`application/x-www-form-urlencoded`,亦支持 multipart`text` 为必需):
| 参数 | 类型 | 必需 | 默认 | 说明 |
|---|---|---|---|---|
| `code` | string,可选;自定义提取码,5-8 位字母或数字(空=随机生成;占用 400「该提取码已被占用」) |
| `text` | string | ✅ | - | 文本内容(≤222KB,按 UTF-8 字节数) |
| `expire_value` | int | ❌ | `1` | 过期值(配合 `expire_style` |
| `expire_style` | string | ❌ | `day` | `day`/`hour`/`minute`/`count`/`forever`(须在站点允许列表内) |
过期语义:
- `day`/`hour`/`minute`:按时间过期,`expired_count = -1`
- `count`:按次数过期,取件 `expire_value` 次后失效(`expired_count = expire_value`);
**26.9 需求 ④**`max_save_count>0``expire_value` 不得超出该上限,超限 403。
- `forever`:永久(需站点允许;`max_save_seconds>0` 时其他方式受最长保存上限约束,超限 403)。
> 可选值与上限来自公开配置 `GET /api/v1/config``expireStyle`、`max_save_seconds`、
> `max_save_count`),上传页动态读取并在范围内选择;管理端改策略后立即生效。
**curl 示例**
```bash
# 自定义提取码(可选):-d 'code=MYCODE1'
curl -s -X POST http://localhost:8466/share/text \
-d 'text=你好,文件快传' \
-d 'expire_value=1' \
-d 'expire_style=day'
```
**成功响应**200):
```json
{ "code": 200, "msg": "ok", "data": { "code": "8XQ2M" } }
```
`data.code` 为 5 位取件码(数字或大写字母+数字,取决于 `code_generate_type`)。
**错误响应**
```json
{ "code": 400, "msg": "过期时间类型错误" }
```
```json
{ "code": 400, "msg": "过期时间值必须大于 0" }
```
```json
{ "code": 403, "msg": "内容过多,建议采用文件形式" }
```
```json
{ "code": 403, "msg": "限制最长时间为 7天,可换用其他方式" }
```
```json
{ "code": 403, "msg": "限制次数最多为 5 次" }
```
```json
{ "code": 423, "msg": "请求次数过多,请稍后再试" }
```
> 游客上传关闭(`openUpload=0`)时需携带管理员令牌,否则 403:
> `{"code":403,"msg":"本站未开启游客上传,如需上传请先登录后台"}`
## 取回文本
文本分享的取回走统一的取件接口(消耗次数):
- `GET /share/select?code=<code>``text/plain` 正文即文本内容(响应头 `Content-Disposition` 带文件名,无扩展名时为 `<prefix>.txt`)。
- `POST /share/select``{"code":"8XQ2M"}`)→ JSON`data.text` / `data.content` 为文本内容。
示例:
```bash
curl -s "http://localhost:8466/share/select?code=8XQ2M"
```
```text
你好,文件快传
```
**26.9 变更**:① 支持 JSON 提交(`Content-Type: application/json`,字段同名);② 空文本 400「分享内容不能为空」;③ 可选 `code` 自定义提取码(5-8 位字母数字,占用 400)。