Browse Source

feat(nc-gui): verify mime type when uploading attachment

pull/4931/head
Wing-Kam Wong 2 years ago
parent
commit
0612daed91
  1. 7
      packages/nc-gui/components/cell/attachment/utils.ts

7
packages/nc-gui/components/cell/attachment/utils.ts

@ -118,6 +118,13 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
const newAttachments = [] const newAttachments = []
for (let file of selectedFiles) { for (let file of selectedFiles) {
// verify mime type
const meta = typeof column.value?.meta === 'string' ? JSON.parse(column.value.meta) : column.value?.meta
if (meta.unsupportedAttachmentMimeTypes.includes(file.type)) {
message.error(`${file.name} has the mime type ${file.type} which is not allowed in this column.`)
continue
}
file = await renameFile(file) file = await renameFile(file)
try { try {
const data = await api.storage.upload( const data = await api.storage.upload(

Loading…
Cancel
Save