From b953fe4dc0a4d01296da299f69ab47d6c4890047 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 17 Oct 2023 12:06:00 +0000 Subject: [PATCH] fix: upload by url attachment file names --- packages/nocodb/src/services/attachments.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/services/attachments.service.ts b/packages/nocodb/src/services/attachments.service.ts index 873c86c103..c8e835e61f 100644 --- a/packages/nocodb/src/services/attachments.service.ts +++ b/packages/nocodb/src/services/attachments.service.ts @@ -111,7 +111,9 @@ export class AttachmentsService { param.urls?.map?.(async (urlMeta) => { const { url, fileName: _fileName } = urlMeta; - const fileName = `${nanoid(18)}${_fileName || url.split('/').pop()}`; + const fileName = `${nanoid(18)}${path.extname( + _fileName || url.split('/').pop(), + )}`; const attachmentUrl = await (storageAdapter as any).fileCreateByUrl( slash(path.join(destPath, fileName)), @@ -130,7 +132,7 @@ export class AttachmentsService { return { ...(attachmentUrl ? { url: attachmentUrl } : {}), ...(attachmentPath ? { path: attachmentPath } : {}), - title: fileName, + title: _fileName, mimetype: urlMeta.mimetype, size: urlMeta.size, icon: mimeIcons[path.extname(fileName).slice(1)] || undefined,