update: chunk upload

This commit is contained in:
tao.chen
2026-09-11 20:02:47 +08:00
parent 51f1fe96bf
commit d225b6e182
7 changed files with 584 additions and 13 deletions
+17
View File
@@ -1,5 +1,22 @@
'use strict';
// ---------------------------------------------------------------------------
// 大文件分片上传常量 (见 app.js uploadChunked/uploadOneChunk)
// ---------------------------------------------------------------------------
const CHUNK_THRESHOLD = 5 * 1024 * 1024 * 1024; // >5GB 走分片
const CHUNK_SIZE = 1 * 1024 * 1024 * 1024; // 每片 1GB
function uuid() {
// crypto.randomUUID 仅在 secure context (HTTPS / localhost) 可用, HTTP 非 localhost 会抛.
// 用 crypto.getRandomValues (所有现代浏览器均支持, 不要求 secure context) 手动拼一个 v4.
const b = new Uint8Array(16);
crypto.getRandomValues(b);
b[6] = (b[6] & 0x0f) | 0x40; // version 4
b[8] = (b[8] & 0x3f) | 0x80; // variant RFC 4122
const h = [...b].map(x => x.toString(16).padStart(2, '0')).join('');
return `${h.slice(0,8)}-${h.slice(8,12)}-${h.slice(12,16)}-${h.slice(16,20)}-${h.slice(20)}`;
}
// ---------------------------------------------------------------------------
// 纯函数 + 倒计时 interval
// 跨文件共享 (classic <script> 加载顺序: app.js → helpers.js → batch.js).