update: chunk upload
This commit is contained in:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user