feat(upload): resumable chunked upload protocol for large files — init(parts≤32MB)/status/complete endpoints with fingerprint-derived deterministic uploadId (same file resumes, no restart), sessions in BOOKS_DIR/.uploads with 24h sweep, frontend uploadBook auto-switches >16MB to 8MB parts (retry x3 in place, skip received); oversize single POST now reports honest 413 too_large instead of "multipart field 'file' required" (was MaxBytesReader abort mislabeled); UPLOAD_MAX_MB wired into both compose stacks (cap total, .env.example 2048), nginx body limit drops to 32m; testCfg limit 1MB, CJK/fullwidth-colon filename proven unaffected; e2e verified with 311MB real file (39 parts, sha1 match)

This commit is contained in:
2026-09-07 23:56:40 +08:00
parent aba1e58fa6
commit 7d650107d2
12 changed files with 540 additions and 10 deletions
+3 -1
View File
@@ -2,10 +2,12 @@ JWT_SECRET=change-me-openssl-rand-hex-32
ADMIN_USER=admin
ADMIN_PASSWORD=change-me-min-8
SCAN_INTERVAL_SEC=60
# 上传总大小上限(MB)。前端 >16MB 自动分片(每片 8MB),nginx 体积限制只需盖住单个分片
UPLOAD_MAX_MB=2048
# ---- 部署参数(deploy/prepare.sh 渲染模板 / compose 插值用) ----
WEB_PORT=8080
NGINX_CLIENT_MAX_BODY_SIZE=200m
NGINX_CLIENT_MAX_BODY_SIZE=32m
REDIS_MAXMEMORY=128mb
REDIS_MAXMEMORY_POLICY=allkeys-lru
DELVE_PORT=2345
+1
View File
@@ -28,6 +28,7 @@ services:
BOOKS_DIR: /data/books
CACHE_DIR: /data/books/cache
SCAN_INTERVAL_SEC: ${SCAN_INTERVAL_SEC:-60}
UPLOAD_MAX_MB: ${UPLOAD_MAX_MB:-200}
volumes:
- ../backend:/app
- ./api/storage:/data/books
+1
View File
@@ -22,6 +22,7 @@ services:
BOOKS_DIR: /data/books
CACHE_DIR: /data/books/cache
SCAN_INTERVAL_SEC: ${SCAN_INTERVAL_SEC:-60}
UPLOAD_MAX_MB: ${UPLOAD_MAX_MB:-200}
volumes:
- ./api/storage:/data/books
depends_on: