WIP: добавить MVP загрузки вложений в Cloudflare R2

Работа ещё не готова: предпросмотр публичных R2-вложений в UI пока не завершён.
This commit is contained in:
AidarKC
2026-11-15 00:48:41 +03:00
parent 97db033eb8
commit 2f5736e67d
16 changed files with 361 additions and 72 deletions
@@ -0,0 +1,13 @@
import assert from 'node:assert/strict';
import { preparePublicFile, fileMime } from '../../shine-UI/js/services/file-preparation-service.js';
assert.equal(fileMime(new File(['x'], 'clip.mp4', { type: '' })), 'video/mp4');
assert.equal(fileMime(new File(['x'], 'mystery', { type: '' })), 'application/octet-stream');
for (const size of [1, 16384, 16385, 1048576, 1048577, 2097152]) {
const blob = new File([new Uint8Array(size)], 'data.bin');
const prepared = await preparePublicFile(blob);
assert.equal(prepared.size, size);
assert.match(prepared.pr, /^[A-Za-z0-9_-]{43}$/);
assert.equal((await preparePublicFile(blob)).pr, prepared.pr);
}
console.log('R2 client preparation smoke tests OK');