Перевести вложения DM на R2 и обновить файловый API

This commit is contained in:
AidarKC
2026-11-15 14:33:52 +03:00
parent 3ecec25fce
commit 70540ff041
23 changed files with 770 additions and 202 deletions
@@ -1,4 +1,4 @@
import { bytesToBase64Url } from './crypto-utils.js';
import { encodePublicPiecesRoot } from './public-pieces-root.js';
import { computeTorrentV2PieceRoot, TorrentV2PieceAccumulator, TORRENT_V2_PIECE_BYTES } from './torrent-v2-service.js';
export const R2_MAX_FILE_BYTES = 500 * 1024 * 1024;
@@ -18,5 +18,5 @@ export async function preparePublicFile(file, { onProgress = null } = {}) {
onProgress?.(Math.min(file.size, offset + bytes.byteLength), file.size);
}
const root = await accumulator.finalize();
return { file, name: String(file.name || 'file'), size: file.size, mm: fileMime(file), pr: bytesToBase64Url(root) };
return { file, name: String(file.name || 'file'), size: file.size, mm: fileMime(file), pr: encodePublicPiecesRoot(root) };
}