From 64fde4bb0d450e728e233bbd4cd70a61610f2c24 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer <7229+djmaze@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:49:20 +0100 Subject: [PATCH] Do not check mime type during attachment download Also, just do a HEAD request instead of downloading the whole file. --- packages/nc-gui/composables/useAttachment.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/composables/useAttachment.ts b/packages/nc-gui/composables/useAttachment.ts index 637c2666a4..7119d13c9d 100644 --- a/packages/nc-gui/composables/useAttachment.ts +++ b/packages/nc-gui/composables/useAttachment.ts @@ -1,4 +1,4 @@ -import { mimeTypes, openLink, useGlobal } from '#imports' +import { openLink, useGlobal } from '#imports' const useAttachment = () => { const { appInfo } = useGlobal() @@ -15,11 +15,10 @@ const useAttachment = () => { return item.data } const sources = getPossibleAttachmentSrc(item) - const mimeType = mimeTypes[item?.mimetype?.split('/')?.pop() || 'txt'] for (const source of sources) { // test if the source is accessible or not - const res = await fetch(source) - if (res.ok && res.headers.get('Content-Type') === mimeType) { + const res = await fetch(source, { method: 'HEAD' }) + if (res.ok) { return source } }