From d8f8bda96b78cb575b514908f65605df4a91a5ed Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 19 Jan 2023 19:42:17 +0800 Subject: [PATCH] feat(nc-gui): remove rename upon upload --- .../components/cell/attachment/utils.ts | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/nc-gui/components/cell/attachment/utils.ts b/packages/nc-gui/components/cell/attachment/utils.ts index 9d8bbd5b41..baafb5f9f7 100644 --- a/packages/nc-gui/components/cell/attachment/utils.ts +++ b/packages/nc-gui/components/cell/attachment/utils.ts @@ -95,29 +95,26 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( new Promise((resolve) => { const res: AttachmentProps = { ...file, file, title: file.name, mimetype: file.type } - renameFile(file).then((renamedFile) => { - if (isImage(renamedFile.name, (renamedFile).mimetype ?? renamedFile.type)) { - const reader = new FileReader() + if (isImage(file.name, (file).mimetype ?? file.type)) { + const reader = new FileReader() - reader.onload = (e) => { - res.data = e.target?.result + reader.onload = (e) => { + res.data = e.target?.result - resolve(res) - } - - reader.onerror = () => { - resolve(res) - } + resolve(res) + } - reader.readAsDataURL(file) - } else { + reader.onerror = () => { resolve(res) } - }) + + reader.readAsDataURL(file) + } else { + resolve(res) + } }), ), ) - attachments.value = [...attachments.value, ...newFiles] return updateModelValue(attachments.value) @@ -152,8 +149,6 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState( continue } - file = await renameFile(file) - files.push(file) }