diff --git a/backend/.env.development b/backend/.env.development index dcdb8be7..43f37501 100644 --- a/backend/.env.development +++ b/backend/.env.development @@ -68,6 +68,7 @@ LANGCHAIN_API_KEY=your_langsmith_api_key_here LANGCHAIN_PROJECT=your_langsmith_project_name_here # FILE_UPLOAD: Whether to enable file upload to storage +# Available options: false, s3, minio # If set to false, AWS_S3_BUCKET_NAME is not required. # Set to true if file upload is required. FILE_UPLOAD=false diff --git a/backend/docker/docker-compose-full.yml b/backend/docker/docker-compose-full.yml index 17d956d9..233ff1f3 100644 --- a/backend/docker/docker-compose-full.yml +++ b/backend/docker/docker-compose-full.yml @@ -27,11 +27,12 @@ services: LANGCHAIN_API_KEY: "your_langsmith_api_key_here" LANGCHAIN_PROJECT: "your_langsmith_project_name_here" FILE_UPLOAD: false - BUCKET_TYPE: "S3 or MINIO" - BUCKET_NAME: "your_s3_bucket_name_here" - MINIO_ENDPOINT: "your_minio_endpoint_here" - MINIO_ACCESS_KEY: "your_minio_access_key_here" - MINIO_SECRET_KEY: "your_minio_secret_key_here" + AWS_REGION: "your_aws_region_here" + # Default configuration values for using Minio + BUCKET_NAME: "default-storage" + MINIO_ENDPOINT: "http://localhost:9000" + STORAGE_ACCESS_KEY: "minioadmin" + STORAGE_SECRET_KEY: "minioadmin" ports: - "3000:3000" depends_on: diff --git a/backend/src/storage/storage.module.ts b/backend/src/storage/storage.module.ts index ce18a69a..b75a261a 100644 --- a/backend/src/storage/storage.module.ts +++ b/backend/src/storage/storage.module.ts @@ -5,7 +5,7 @@ import { ConfigService } from "@nestjs/config"; const s3ClientFactory = { provide: "STORAGE_CLIENT", useFactory: (configService: ConfigService): S3Client | null => { - const fileUpload = configService.get("FILE_UPLOAD"); + const fileUpload = configService.get("FILE_UPLOAD"); if (!fileUpload) { return null; } @@ -14,19 +14,17 @@ const s3ClientFactory = { const accessKeyId = configService.get("STORAGE_ACCESS_KEY"); const secretAccessKey = configService.get("STORAGE_SECRET_KEY"); - const config: S3ClientConfig = fileUpload - ? { - region, - endpoint, - forcePathStyle: true, - credentials: { - accessKeyId, - secretAccessKey, - }, - } - : { - region, - }; + const config: S3ClientConfig = { + region, + ...(fileUpload === "minio" && { + endpoint, + forcePathStyle: true, + credentials: { + accessKeyId, + secretAccessKey, + }, + }), + }; return new S3Client(config); },