파일을 다운로드할 때 전체 파일을 메모리에 올리는 대신 서비스 워커에서 스트리밍으로 복호화하도록 변경

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
staticandClaude Opus 5.5 committed 2026-10-12 00:48:21 +09:00
1 parent 877cf9c42e
commit 3e52fa7a7c
29 files changed
+629 -467

No files matched your search

@@ -1,5 +1,4 @@
<script lang="ts">
import FileSaver from "file-saver";
import type { Component } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";
import { fly } from "svelte/transition";
@@ -12,39 +11,24 @@
interface Props {
directoryId?: "root" | number;
downloadUrl?: string;
fileBlob?: Blob;
filename?: string;
isFavorite?: boolean;
isOpen: boolean;
onDownloadClick?: () => void;
onToggleFavorite?: () => void;
}
let {
directoryId,
downloadUrl,
fileBlob,
filename,
isFavorite,
isOpen = $bindable(),
onDownloadClick,
onToggleFavorite,
}: Props = $props();
const handleDownload = () => {
if (fileBlob && filename) {
FileSaver.saveAs(fileBlob, filename);
} else if (downloadUrl && filename) {
// Use streaming download via Content-Disposition header
const url = new URL(downloadUrl, window.location.origin);
url.searchParams.set("download", filename);
window.open(url.toString(), "_blank");
}
};
</script>
<svelte:window onclick={() => (isOpen = false)} />
{#if isOpen && (directoryId || downloadUrl || fileBlob)}
{#if isOpen && (directoryId || onDownloadClick || isFavorite !== undefined)}
<div
class="absolute top-full right-2 z-20 min-w-44 space-y-1 rounded-lg bg-white px-1 py-2 shadow-2xl"
transition:fly={{ y: -8, duration: 200 }}
@@ -80,8 +64,8 @@
),
)}
{/if}
{#if fileBlob || downloadUrl}
{@render menuButton(IconCloudDownload, "다운로드", handleDownload)}
{#if onDownloadClick}
{@render menuButton(IconCloudDownload, "다운로드", onDownloadClick)}
{/if}
</div>
</div>