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 b3829e1d..be980b60 100644 --- a/tdrive/backend/node/src/core/platform/services/storage/index.ts +++ b/tdrive/backend/node/src/core/platform/services/storage/index.ts @@ -23,6 +23,7 @@ export default class StorageService extends TdriveService implements private encryptionOptions: EncryptionConfiguration; private algorithm = "aes-256-cbc"; + private homeDir = "tdrive"; api(): StorageAPI { return this; @@ -37,6 +38,7 @@ 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"); return new S3ConnectorService({ bucket: this.configuration.get("S3.bucket"), region: this.configuration.get("S3.region"), @@ -56,6 +58,10 @@ export default class StorageService extends TdriveService implements return new LocalConnectorService(this.configuration.get("local")); } + getHomeDir(): string { + return this.homeDir; + } + async write(path: string, stream: Stream, options?: WriteOptions): Promise { try { if (options?.encryptionKey) { diff --git a/tdrive/backend/node/src/core/platform/services/storage/provider.ts b/tdrive/backend/node/src/core/platform/services/storage/provider.ts index 8a9c1d48..2112405f 100644 --- a/tdrive/backend/node/src/core/platform/services/storage/provider.ts +++ b/tdrive/backend/node/src/core/platform/services/storage/provider.ts @@ -54,4 +54,5 @@ export interface StorageConnectorAPI { export default interface StorageAPI extends TdriveServiceProvider, StorageConnectorAPI { getConnector(): StorageConnectorAPI; getConnectorType(): string; + getHomeDir(): string; } diff --git a/tdrive/backend/node/src/services/files/services/index.ts b/tdrive/backend/node/src/services/files/services/index.ts index 3081211f..56729d89 100644 --- a/tdrive/backend/node/src/services/files/services/index.ts +++ b/tdrive/backend/node/src/services/files/services/index.ts @@ -311,5 +311,7 @@ export class FileServiceImpl { } function getFilePath(entity: File): string { - return `/tdrive/files/${entity.company_id}/${entity.user_id || "anonymous"}/${entity.id}`; + return `/${gr.platformServices.storage.getHomeDir()}/files/${entity.company_id}/${ + entity.user_id || "anonymous" + }/${entity.id}`; }