From b7544d82f37df5d81fcf4300533ad7e80a9ea412 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 4 Jun 2025 18:37:41 +0200 Subject: [PATCH] Add proxy downloads and bulk file operations - Implement proxy download endpoint for better mobile Safari compatibility - Add bulk selection with checkboxes in file browser - Add bulk actions bar for downloading/deleting selected files - Replace direct S3 downloads with server-proxied downloads - Fix download issues on mobile devices by using proper link handling --- components/FilePreviewModal.vue | 17 ++-- pages/dashboard/file-browser.vue | 133 +++++++++++++++++++++++++++-- server/api/files/proxy-download.ts | 56 ++++++++++++ 3 files changed, 190 insertions(+), 16 deletions(-) create mode 100644 server/api/files/proxy-download.ts diff --git a/components/FilePreviewModal.vue b/components/FilePreviewModal.vue index 78761d9..aba8666 100644 --- a/components/FilePreviewModal.vue +++ b/components/FilePreviewModal.vue @@ -204,14 +204,12 @@ const downloadFile = async () => { if (!props.file) return; try { - const response = await $fetch('/api/files/download', { - params: { fileName: props.file.name }, - }); + // Use proxy download endpoint for better mobile compatibility + const proxyUrl = `/api/files/proxy-download?fileName=${encodeURIComponent(props.file.name)}`; - // For mobile Safari, we need to use a different approach + // Create a link element const link = document.createElement('a'); - link.href = response.url; - link.target = '_blank'; + link.href = proxyUrl; // Extract clean filename for download let filename = props.file.displayName; @@ -220,9 +218,14 @@ const downloadFile = async () => { } link.download = filename; + link.style.display = 'none'; document.body.appendChild(link); link.click(); - document.body.removeChild(link); + + // Clean up + setTimeout(() => { + document.body.removeChild(link); + }, 100); } catch (err) { console.error('Failed to download file:', err); } diff --git a/pages/dashboard/file-browser.vue b/pages/dashboard/file-browser.vue index ae7ade4..b415ae9 100644 --- a/pages/dashboard/file-browser.vue +++ b/pages/dashboard/file-browser.vue @@ -63,14 +63,52 @@ + + + + +
+ {{ selectedItems.length }} item(s) selected +
+ + Download + + + Delete + +
+
+
+
+
+