b23335d5fb
docs: reorganize api docs into categorized subdirectories and fill missing docs - Categorize 77 existing api docs into 16 business-domain subdirectories (auth/ad/wallet/coupon/compare/savings/signin/tasks/invite/user/ device/platform/intent/meituan/other) plus admin/ and internal/ - Split admin/ into 7 sub-resource subdirectories (auth/users/wallet/ withdraws/feedbacks/admins/ad) with 4 single-file docs at root - Create 21 new docs covering 28 previously undocumented endpoints: ad/watch-report, wallet/transfer-auth (3 endpoints), coupon/session+ stats+completed-today+prompt (7), invite/me+invitees+bind+landing-track, user/onboarding (2), platform/flags+ad-config+app-version, intent/step+precoupon/step, analytics/events, order/report, report/submit+records, feedback/config+records, trace/finalize - Add mock request/response JSON examples to all new docs - Create docs/README.md with full category index for LLM navigation - Update docs/api/README.md: fix all links, add new endpoint rows, replace "no doc" markers with actual links - Fix back-navigation links (./README.md -> ../README.md or ../../README.md) in all moved files @
1.5 KiB
1.5 KiB
POST /api/v1/user/avatar — 上传头像
所属:User 组(前缀
/api/v1/user) | 鉴权:Bearer access_token | ← 返回 API 索引
入参
multipart/form-data:
| 字段 | 类型 | 说明 |
|---|---|---|
file |
file | 头像图片,仅 JPEG / PNG / WebP,≤ 5 MB |
服务端按文件头魔数嗅探真实类型(
FF D8 FF/89 50 4E 47/RIFF…WEBP),不信任 Content-Type 与文件名;不在三种之内的一律拒。
出参
响应 200:UserOut(avatar_url 字段已更新为新地址,形如 /media/avatars/u<uid>_<rand>.jpg)。结构见 API 索引。
返回相对路径——客户端按自己的
BASE_URL拼绝对地址(dev 下10.0.2.2/LAN IP 都可能,服务端不知道客户端怎么访问到自己)。读图走 /media 静态服务 的GET /media/...。
错误码
400空文件 / 超过 5 MB / 非 JPEG/PNG/WebP401未带 token / token 无效或过期 / 用户被禁用422缺file字段
说明
- 旧头像清理:落库成功后才删旧文件,避免"删了新的没存上"的丢图风险;非本服务托管的 URL(如微信头像)不动
- 文件名服务端随机生成
u<user_id>_<16 位 hex>.<ext>,杜绝路径穿越与覆盖 - 存储目录:
settings.MEDIA_ROOT/avatars/,默认data/media/avatars/(生产 nginx 注意把它放共享卷或对象存储,见 后端技术实现.md)