🪣 S3 home directory for files

This commit is contained in:
Montassar Ghanmy
2023-09-28 17:04:41 +01:00
committed by GitHub
parent a6fa4240b5
commit b020118a6a
3 changed files with 10 additions and 1 deletions
@@ -23,6 +23,7 @@ export default class StorageService extends TdriveService<StorageAPI> 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<StorageAPI> implements
const type = this.getConnectorType();
if (type === "S3") {
logger.info("Using 'S3' connector for storage.");
this.homeDir = this.configuration.get<string>("S3.bucket");
return new S3ConnectorService({
bucket: this.configuration.get<string>("S3.bucket"),
region: this.configuration.get<string>("S3.region"),
@@ -56,6 +58,10 @@ export default class StorageService extends TdriveService<StorageAPI> implements
return new LocalConnectorService(this.configuration.get<LocalConfiguration>("local"));
}
getHomeDir(): string {
return this.homeDir;
}
async write(path: string, stream: Stream, options?: WriteOptions): Promise<WriteMetadata> {
try {
if (options?.encryptionKey) {
@@ -54,4 +54,5 @@ export interface StorageConnectorAPI {
export default interface StorageAPI extends TdriveServiceProvider, StorageConnectorAPI {
getConnector(): StorageConnectorAPI;
getConnectorType(): string;
getHomeDir(): string;
}
@@ -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}`;
}