From 6c4bd590f056520fd4dc6d0e8e083e857a6f6034 Mon Sep 17 00:00:00 2001 From: static Date: Mon, 6 Jan 2025 23:50:03 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B8=8C=EB=9D=BC=EC=9A=B0=EC=A0=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20HEIF=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20?= =?UTF-8?q?=EC=A0=9C=EB=8C=80=EB=A1=9C=20=ED=91=9C=ED=98=84=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EB=AA=BB=ED=95=98=EB=8D=98=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(fullscreen)/file/[id]/+page.svelte | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/routes/(fullscreen)/file/[id]/+page.svelte b/src/routes/(fullscreen)/file/[id]/+page.svelte index 51d7e21..c5e822e 100644 --- a/src/routes/(fullscreen)/file/[id]/+page.svelte +++ b/src/routes/(fullscreen)/file/[id]/+page.svelte @@ -32,24 +32,22 @@ untrack(() => { isDownloaded = true; + if ($info.contentType.startsWith("image")) { + contentType = "image"; + } else if ($info.contentType.startsWith("video")) { + contentType = "video"; + } + requestFileDownload(data.id, $info.contentIv, $info.dataKey).then(async (res) => { content = new Blob([res], { type: $info.contentType }); if (content.type === "image/heic" || content.type === "image/heif") { contentUrl = URL.createObjectURL( (await heic2any({ blob: content, toType: "image/jpeg" })) as Blob, ); - } else { + } else if (contentType) { contentUrl = URL.createObjectURL(content); - } - - if (content.type.startsWith("image")) { - contentType = "image"; - } else if (content.type.startsWith("video")) { - contentType = "video"; - } - - if (!contentType) { - FileSaver.saveAs(new Blob([res], { type: $info.contentType }), $info.name); + } else { + FileSaver.saveAs(content, $info.name); } }); }); @@ -80,18 +78,16 @@ {/snippet} - {#if contentType === "image"} - {#if $info && content} - {@const src = URL.createObjectURL(new Blob([content], { type: $info.contentType }))} - {$info.name} + {#if $info && contentType === "image"} + {#if contentUrl} + {$info.name} {:else} {@render viewerLoading("이미지를 불러오고 있어요.")} {/if} {:else if contentType === "video"} - {#if $info && content} - {@const src = URL.createObjectURL(new Blob([content], { type: $info.contentType }))} + {#if contentUrl} - + {:else} {@render viewerLoading("비디오를 불러오고 있어요.")} {/if}