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 1 year 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 { 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
}
}

Loading…
Cancel
Save