diff --git a/.env.example b/.env.example index 242eb02..cfd43bf 100644 --- a/.env.example +++ b/.env.example @@ -12,4 +12,5 @@ S3_SECRET_ACCESS_KEY= # optional if provider is s3 S3_REGION= S3_SESSION_TOKEN= -S3_FORCE_PATH_STYLE= \ No newline at end of file +S3_FORCE_PATH_STYLE= +S3_ENDPOINT= \ No newline at end of file diff --git a/README.md b/README.md index e43ce73..1a77019 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ S3_SECRET_ACCESS_KEY= S3_REGION= S3_SESSION_TOKEN= S3_FORCE_PATH_STYLE= +S3_ENDPOINT= ``` ```sh diff --git a/src/config/configuration.ts b/src/config/configuration.ts index db9b2b2..99b5837 100644 --- a/src/config/configuration.ts +++ b/src/config/configuration.ts @@ -8,8 +8,9 @@ const configurationSchema = z S3_ACCESS_KEY_ID: z.string(), S3_SECRET_ACCESS_KEY: z.string(), S3_SESSION_TOKEN: z.string().optional(), - S3_REGION: z.string().optional(), + S3_REGION: z.string().default("us-east-1"), S3_FORCE_PATH_STYLE: z.coerce.boolean().default(false), + S3_ENDPOINT: z.string().optional(), }), z.object({ STORAGE_PROVIDER: z.literal("local"), @@ -35,6 +36,7 @@ const configurationSchema = z }, region: data.S3_REGION, forcePathStyle: data.S3_FORCE_PATH_STYLE, + endpoint: data.S3_ENDPOINT, }, }, ); diff --git a/src/storage/storage.service.ts b/src/storage/storage.service.ts index 57f6a8c..0ba446f 100644 --- a/src/storage/storage.service.ts +++ b/src/storage/storage.service.ts @@ -20,8 +20,14 @@ export class StorageService { const { basePath } = storageConfig; this.driver = new LocalStorageDriver(basePath); } else if (storageConfig.provider === "s3") { - const { bucket, credentials, region, forcePathStyle } = storageConfig; - const s3Client = new S3Client({ credentials, region, forcePathStyle }); + const { bucket, credentials, region, forcePathStyle, endpoint } = + storageConfig; + const s3Client = new S3Client({ + credentials, + region, + forcePathStyle, + endpoint, + }); this.driver = new S3StorageDriver(bucket, s3Client); } }