썸네일 표시 구현

This commit is contained in:
static
2025-07-05 18:18:10 +09:00
parent eaf2d7f202
commit 9e67920968
4 changed files with 66 additions and 3 deletions

View File

@@ -0,0 +1,17 @@
import { callGetApi } from "$lib/hooks";
import { decryptData } from "$lib/modules/crypto";
import type { FileThumbnailInfoResponse } from "$lib/server/schemas";
export const getFileThumbnail = async (fileId: number, dataKey: CryptoKey) => {
let res = await callGetApi(`/api/file/${fileId}/thumbnail`);
if (!res.ok) return null;
const { contentIv: thumbnailEncryptedIv }: FileThumbnailInfoResponse = await res.json();
res = await callGetApi(`/api/file/${fileId}/thumbnail/download`);
if (!res.ok) return null;
const thumbnailEncrypted = await res.arrayBuffer();
const thumbnail = await decryptData(thumbnailEncrypted, thumbnailEncryptedIv, dataKey);
return thumbnail;
};