From 18758cb829c90ba8b7400b366f0cd96ecf9e8056 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 10 Nov 2022 19:13:03 +0800 Subject: [PATCH] feat(nocodb): write temp file to os.tmpdir() instead of process.cwd --- packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts | 3 ++- packages/nocodb/src/lib/plugins/gcs/Gcs.ts | 3 ++- packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts | 3 ++- packages/nocodb/src/lib/plugins/mino/Minio.ts | 3 ++- packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts | 3 ++- packages/nocodb/src/lib/plugins/s3/S3.ts | 3 ++- .../nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts | 3 ++- packages/nocodb/src/lib/plugins/spaces/Spaces.ts | 3 ++- packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts | 3 ++- packages/nocodb/src/lib/plugins/vultr/Vultr.ts | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts index ad6ab55f7f..c74ae89c24 100644 --- a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts @@ -1,5 +1,6 @@ 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'; @@ -119,7 +120,7 @@ export default class Backblaze implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 7a696e84d9..e32bbc9a50 100644 --- a/packages/nocodb/src/lib/plugins/gcs/Gcs.ts +++ b/packages/nocodb/src/lib/plugins/gcs/Gcs.ts @@ -1,5 +1,6 @@ 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'; @@ -85,7 +86,7 @@ export default class Gcs implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 a2d6b5a1b9..e2ca8f5e16 100644 --- a/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts +++ b/packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts @@ -1,5 +1,6 @@ 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'; @@ -109,7 +110,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 101547a0c5..54139b6c39 100644 --- a/packages/nocodb/src/lib/plugins/mino/Minio.ts +++ b/packages/nocodb/src/lib/plugins/mino/Minio.ts @@ -1,5 +1,6 @@ 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'; @@ -73,7 +74,7 @@ export default class Minio implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 fc075b40a7..634255e5a8 100644 --- a/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts +++ b/packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts @@ -1,5 +1,6 @@ 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'; @@ -109,7 +110,7 @@ export default class OvhCloud implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 3d6a44721d..72f20dbab9 100644 --- a/packages/nocodb/src/lib/plugins/s3/S3.ts +++ b/packages/nocodb/src/lib/plugins/s3/S3.ts @@ -1,5 +1,6 @@ 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'; @@ -112,7 +113,7 @@ export default class S3 implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 4b21d5c1c3..28df116bf0 100644 --- a/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts +++ b/packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts @@ -1,5 +1,6 @@ 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'; @@ -29,7 +30,7 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 025a859029..0d78cc038e 100644 --- a/packages/nocodb/src/lib/plugins/spaces/Spaces.ts +++ b/packages/nocodb/src/lib/plugins/spaces/Spaces.ts @@ -1,5 +1,6 @@ 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'; @@ -117,7 +118,7 @@ export default class Spaces implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 cda09a9be7..cf63a7d1eb 100644 --- a/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts +++ b/packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts @@ -1,5 +1,6 @@ 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'; @@ -107,7 +108,7 @@ export default class UpoCloud implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); 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 8729703161..146397d526 100644 --- a/packages/nocodb/src/lib/plugins/vultr/Vultr.ts +++ b/packages/nocodb/src/lib/plugins/vultr/Vultr.ts @@ -1,5 +1,6 @@ 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'; @@ -109,7 +110,7 @@ export default class Vultr implements IStorageAdapterV2 { public async test(): Promise { try { - const tempFile = path.join(process.cwd(), 'temp.txt'); + const tempFile = path.join(os.tmpdir(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); await waitForStreamClose(createStream); await this.fileCreate('nc-test-file.txt', {