From 3ed5d1dd5815297c027d4206aabc911cb0043fff Mon Sep 17 00:00:00 2001 From: Carlos Lostao Date: Thu, 30 Jan 2025 20:11:24 +0100 Subject: [PATCH 1/3] fix: remove auth check for public download link --- backend/src/controllers/object.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/src/controllers/object.ts b/backend/src/controllers/object.ts index 8aec539..78c2695 100644 --- a/backend/src/controllers/object.ts +++ b/backend/src/controllers/object.ts @@ -334,11 +334,6 @@ objectController.get( try { const { id } = req.params - const user = await handleAuth(req, res) - if (!user) { - return - } - const { metadata, startDownload } = await ObjectUseCases.downloadPublishedObject(id) if (!metadata) { From 16bd78161fa0dea5ce8382c3a11264638af63917 Mon Sep 17 00:00:00 2001 From: Carlos Lostao Date: Thu, 30 Jan 2025 20:46:10 +0100 Subject: [PATCH 2/3] chore: add encoding if applies --- backend/src/controllers/object.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/controllers/object.ts b/backend/src/controllers/object.ts index 78c2695..9631982 100644 --- a/backend/src/controllers/object.ts +++ b/backend/src/controllers/object.ts @@ -348,6 +348,12 @@ objectController.get( res.set('Content-Type', metadata.mimeType || 'application/octet-stream') res.set('Content-Disposition', `attachment; filename="${safeName}"`) res.set('Content-Length', metadata.totalSize.toString()) + const compressedButNoEncrypted = + metadata.uploadOptions?.compression && + !metadata.uploadOptions?.encryption + if (compressedButNoEncrypted) { + res.set('Content-Encoding', 'deflate') + } } else { res.set('Content-Type', 'application/zip') res.set('Content-Disposition', `attachment; filename="${safeName}.zip"`) From a325056f65559794f66d942b281bc21e93f29498 Mon Sep 17 00:00:00 2001 From: Carlos Lostao Date: Thu, 30 Jan 2025 20:48:50 +0100 Subject: [PATCH 3/3] chore: remove attachment attribute --- backend/src/controllers/object.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/controllers/object.ts b/backend/src/controllers/object.ts index 9631982..4a0699c 100644 --- a/backend/src/controllers/object.ts +++ b/backend/src/controllers/object.ts @@ -346,7 +346,7 @@ objectController.get( const safeName = encodeURIComponent(metadata.name || 'download') if (metadata.type === 'file') { res.set('Content-Type', metadata.mimeType || 'application/octet-stream') - res.set('Content-Disposition', `attachment; filename="${safeName}"`) + res.set('Content-Disposition', `filename="${safeName}"`) res.set('Content-Length', metadata.totalSize.toString()) const compressedButNoEncrypted = metadata.uploadOptions?.compression && @@ -356,7 +356,7 @@ objectController.get( } } else { res.set('Content-Type', 'application/zip') - res.set('Content-Disposition', `attachment; filename="${safeName}.zip"`) + res.set('Content-Disposition', `filename="${safeName}.zip"`) } pipeline(await startDownload(), res, (err) => {