Browse Source

Do not check mime type during attachment download

Also, just do a HEAD request instead of downloading the whole file.
pull/5181/head
Martin Honermeyer 2 years ago
parent
commit
64fde4bb0d
  1. 7
      packages/nc-gui/composables/useAttachment.ts

7
packages/nc-gui/composables/useAttachment.ts

@ -1,4 +1,4 @@
import { mimeTypes, openLink, useGlobal } from '#imports' import { openLink, useGlobal } from '#imports'
const useAttachment = () => { const useAttachment = () => {
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
@ -15,11 +15,10 @@ const useAttachment = () => {
return item.data return item.data
} }
const sources = getPossibleAttachmentSrc(item) const sources = getPossibleAttachmentSrc(item)
const mimeType = mimeTypes[item?.mimetype?.split('/')?.pop() || 'txt']
for (const source of sources) { for (const source of sources) {
// test if the source is accessible or not // test if the source is accessible or not
const res = await fetch(source) const res = await fetch(source, { method: 'HEAD' })
if (res.ok && res.headers.get('Content-Type') === mimeType) { if (res.ok) {
return source return source
} }
} }

Loading…
Cancel
Save