From df0809ec48c76cac1004dbfb1ded5d3092e6a05b Mon Sep 17 00:00:00 2001 From: Anton Shepilov Date: Tue, 6 Feb 2024 13:44:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8FNew=20configuration=20vari?= =?UTF-8?q?able=20for=20S3=20home=20directory=20(#359)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/config/custom-environment-variables.json | 1 + .../node/src/core/platform/services/storage/index.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tdrive/backend/node/config/custom-environment-variables.json b/tdrive/backend/node/config/custom-environment-variables.json index b13282be..c0b736bd 100644 --- a/tdrive/backend/node/config/custom-environment-variables.json +++ b/tdrive/backend/node/config/custom-environment-variables.json @@ -89,6 +89,7 @@ "path": "STORAGE_LOCAL_PATH" }, "S3": { + "homeDirectory": "STORAGE_S3_HOME_DIRECTORY", "bucket": "STORAGE_S3_BUCKET", "region": "STORAGE_S3_REGION", "endPoint": "STORAGE_S3_ENDPOINT", diff --git a/tdrive/backend/node/src/core/platform/services/storage/index.ts b/tdrive/backend/node/src/core/platform/services/storage/index.ts index cacda65f..e03e69fb 100644 --- a/tdrive/backend/node/src/core/platform/services/storage/index.ts +++ b/tdrive/backend/node/src/core/platform/services/storage/index.ts @@ -38,7 +38,14 @@ export default class StorageService extends TdriveService implements const type = this.getConnectorType(); if (type === "S3") { logger.info("Using 'S3' connector for storage."); - this.homeDir = this.configuration.get("S3.bucket"); + try { + this.homeDir = this.configuration.get("S3.homeDirectory"); + } catch (e) { + this.logger.warn("Home directory is not set, using S3.bucket instead"); + } + if (!this.homeDir) { + this.homeDir = this.configuration.get("S3.bucket"); + } return new S3ConnectorService({ bucket: this.configuration.get("S3.bucket"), region: this.configuration.get("S3.region"),