Browse Source

feat(nc-gui): remove rename upon upload

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

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

@ -95,29 +95,26 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
new Promise<AttachmentProps>((resolve) => { new Promise<AttachmentProps>((resolve) => {
const res: AttachmentProps = { ...file, file, title: file.name, mimetype: file.type } const res: AttachmentProps = { ...file, file, title: file.name, mimetype: file.type }
renameFile(file).then((renamedFile) => { if (isImage(file.name, (<any>file).mimetype ?? file.type)) {
if (isImage(renamedFile.name, (<any>renamedFile).mimetype ?? renamedFile.type)) { const reader = new FileReader()
const reader = new FileReader()
reader.onload = (e) => { reader.onload = (e) => {
res.data = e.target?.result res.data = e.target?.result
resolve(res) resolve(res)
} }
reader.onerror = () => {
resolve(res)
}
reader.readAsDataURL(file) reader.onerror = () => {
} else {
resolve(res) resolve(res)
} }
})
reader.readAsDataURL(file)
} else {
resolve(res)
}
}), }),
), ),
) )
attachments.value = [...attachments.value, ...newFiles] attachments.value = [...attachments.value, ...newFiles]
return updateModelValue(attachments.value) return updateModelValue(attachments.value)
@ -152,8 +149,6 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
continue continue
} }
file = await renameFile(file)
files.push(file) files.push(file)
} }

Loading…
Cancel
Save