diff --git a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts index c74ae89c24..7db4f1f7e7 100644 --- a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class Backblaze implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -120,7 +121,7 @@ export default class Backblaze implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/gcs/Gcs.ts b/packages/nocodb/src/lib/plugins/gcs/Gcs.ts index e32bbc9a50..8e7521cfc5 100644 --- a/packages/nocodb/src/lib/plugins/gcs/Gcs.ts +++ b/packages/nocodb/src/lib/plugins/gcs/Gcs.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import { Storage, StorageOptions } from '@google-cloud/storage'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class Gcs implements IStorageAdapterV2 { private storageClient: Storage; @@ -86,7 +87,7 @@ export default class Gcs implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts b/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts index e2ca8f5e16..c920eff6cf 100644 --- a/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts +++ b/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class LinodeObjectStorage implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -110,7 +111,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/mino/Minio.ts b/packages/nocodb/src/lib/plugins/mino/Minio.ts index 54139b6c39..ef20217604 100644 --- a/packages/nocodb/src/lib/plugins/mino/Minio.ts +++ b/packages/nocodb/src/lib/plugins/mino/Minio.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import { Client as MinioClient } from 'minio'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class Minio implements IStorageAdapterV2 { private minioClient: MinioClient; @@ -74,7 +75,7 @@ export default class Minio implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts b/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts index 634255e5a8..b2e6ed9162 100644 --- a/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts +++ b/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class OvhCloud implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -110,7 +111,7 @@ export default class OvhCloud implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/s3/S3.ts b/packages/nocodb/src/lib/plugins/s3/S3.ts index 72f20dbab9..d1211ff7a1 100644 --- a/packages/nocodb/src/lib/plugins/s3/S3.ts +++ b/packages/nocodb/src/lib/plugins/s3/S3.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class S3 implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -113,7 +114,7 @@ export default class S3 implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts b/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts index 28df116bf0..66034e020e 100644 --- a/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts +++ b/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts @@ -1,10 +1,11 @@ -import path from 'path'; import fs from 'fs'; -import os from 'os'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import AWS from 'aws-sdk'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class ScalewayObjectStorage implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -30,7 +31,7 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/spaces/Spaces.ts b/packages/nocodb/src/lib/plugins/spaces/Spaces.ts index 0d78cc038e..4880b79cb7 100644 --- a/packages/nocodb/src/lib/plugins/spaces/Spaces.ts +++ b/packages/nocodb/src/lib/plugins/spaces/Spaces.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class Spaces implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -118,7 +119,7 @@ export default class Spaces implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts b/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts index cf63a7d1eb..f549634973 100644 --- a/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts +++ b/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class UpoCloud implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -108,7 +109,7 @@ export default class UpoCloud implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/plugins/vultr/Vultr.ts b/packages/nocodb/src/lib/plugins/vultr/Vultr.ts index 146397d526..2a18f0aeb4 100644 --- a/packages/nocodb/src/lib/plugins/vultr/Vultr.ts +++ b/packages/nocodb/src/lib/plugins/vultr/Vultr.ts @@ -1,10 +1,11 @@ import fs from 'fs'; -import path from 'path'; -import os from 'os'; import AWS from 'aws-sdk'; import { IStorageAdapterV2, XcFile } from 'nc-plugin'; import request from 'request'; -import { waitForStreamClose } from '../../utils/pluginUtils'; +import { + waitForStreamClose, + generateTempFilePath, +} from '../../utils/pluginUtils'; export default class Vultr implements IStorageAdapterV2 { private s3Client: AWS.S3; @@ -110,7 +111,7 @@ export default class Vultr implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(os.tmpdir(), 'temp.txt'); + const tempFile = generateTempFilePath(); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', { diff --git a/packages/nocodb/src/lib/utils/pluginUtils.ts b/packages/nocodb/src/lib/utils/pluginUtils.ts index e329b628e7..1772657869 100644 --- a/packages/nocodb/src/lib/utils/pluginUtils.ts +++ b/packages/nocodb/src/lib/utils/pluginUtils.ts @@ -1,4 +1,10 @@ import fs from 'fs'; +import path from 'path'; +import os from 'os'; + +export function generateTempFilePath() { + return path.join(os.tmpdir(), 'temp.txt'); +} export async function waitForStreamClose( stream: fs.WriteStream