diff --git a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts index 1ba80c9bec..eb356349e0 100644 --- a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts @@ -1,4 +1,5 @@ import { promisify } from 'util'; +import moment from 'moment'; import { UITypes } from 'nocodb-sdk'; import Airtable from 'airtable'; import jsonfile from 'jsonfile'; @@ -1544,8 +1545,11 @@ export class AtImportProcessor { ?.map((a) => a.filename?.split('?')?.[0]) .join(', ')}`, ); + const path = `${moment().format('YYYY/MM/DD')}/${hash( + syncDB.user.id, + )}`; tempArr = await this.attachmentsService.uploadViaURL({ - path: `noco/${sDB.baseName}/${table.title}/${key}`, + path, urls: value?.map((attachment) => ({ fileName: attachment.filename?.split('?')?.[0], url: attachment.url, diff --git a/packages/nocodb/src/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/plugins/backblaze/Backblaze.ts index 949bacfd39..ecc6803b40 100644 --- a/packages/nocodb/src/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/plugins/backblaze/Backblaze.ts @@ -54,6 +54,7 @@ export default class Backblaze implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/gcs/Gcs.ts b/packages/nocodb/src/plugins/gcs/Gcs.ts index 34f37c9c5e..0bc7340138 100644 --- a/packages/nocodb/src/plugins/gcs/Gcs.ts +++ b/packages/nocodb/src/plugins/gcs/Gcs.ts @@ -110,6 +110,7 @@ export default class Gcs implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { this.storageClient diff --git a/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts b/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts index 29b658f485..eec1276cdb 100644 --- a/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts +++ b/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts @@ -53,6 +53,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/mino/Minio.ts b/packages/nocodb/src/plugins/mino/Minio.ts index b6a493412e..33d875ea82 100644 --- a/packages/nocodb/src/plugins/mino/Minio.ts +++ b/packages/nocodb/src/plugins/mino/Minio.ts @@ -100,6 +100,7 @@ export default class Minio implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts b/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts index c2eeaa95cb..42281d01a4 100644 --- a/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts +++ b/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts @@ -53,6 +53,7 @@ export default class OvhCloud implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/s3/S3.ts b/packages/nocodb/src/plugins/s3/S3.ts index 5b02391af9..c83180f23b 100644 --- a/packages/nocodb/src/plugins/s3/S3.ts +++ b/packages/nocodb/src/plugins/s3/S3.ts @@ -60,6 +60,7 @@ export default class S3 implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts b/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts index 75c2141906..31ea0de26a 100644 --- a/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts +++ b/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts @@ -103,6 +103,7 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/spaces/Spaces.ts b/packages/nocodb/src/plugins/spaces/Spaces.ts index 998f6b1597..5cfbd9184b 100644 --- a/packages/nocodb/src/plugins/spaces/Spaces.ts +++ b/packages/nocodb/src/plugins/spaces/Spaces.ts @@ -53,6 +53,7 @@ export default class Spaces implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/upcloud/UpoCloud.ts b/packages/nocodb/src/plugins/upcloud/UpoCloud.ts index 019a5dde1e..8e522f058b 100644 --- a/packages/nocodb/src/plugins/upcloud/UpoCloud.ts +++ b/packages/nocodb/src/plugins/upcloud/UpoCloud.ts @@ -53,6 +53,7 @@ export default class UpoCloud implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; diff --git a/packages/nocodb/src/plugins/vultr/Vultr.ts b/packages/nocodb/src/plugins/vultr/Vultr.ts index b0f90a5db3..0a4d29a463 100644 --- a/packages/nocodb/src/plugins/vultr/Vultr.ts +++ b/packages/nocodb/src/plugins/vultr/Vultr.ts @@ -53,6 +53,7 @@ export default class Vultr implements IStorageAdapterV2 { .get(url, { httpAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), httpsAgent: useAgent(url, { stopPortScanningByUrlRedirection: true }), + responseType: 'arraybuffer', }) .then((response) => { uploadParams.Body = response.data; 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,