Add S3 endpoint env variable (#2017)
* - add s3 endpoint * fix .lock * new line
This commit is contained in:
@ -115,7 +115,11 @@ export class EnvironmentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStorageS3Name(): string | undefined {
|
getStorageS3Name(): string | undefined {
|
||||||
return this.configService.get<AwsRegion>('STORAGE_S3_NAME');
|
return this.configService.get<string>('STORAGE_S3_NAME');
|
||||||
|
}
|
||||||
|
|
||||||
|
getStorageS3Endpoint(): string | undefined {
|
||||||
|
return this.configService.get<string>('STORAGE_S3_ENDPOINT');
|
||||||
}
|
}
|
||||||
|
|
||||||
getStorageLocalPath(): string {
|
getStorageLocalPath(): string {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { StorageDriver } from './interfaces/storage-driver.interface';
|
|||||||
|
|
||||||
export interface S3DriverOptions extends S3ClientConfig {
|
export interface S3DriverOptions extends S3ClientConfig {
|
||||||
bucketName: string;
|
bucketName: string;
|
||||||
|
endpoint?: string;
|
||||||
region: string;
|
region: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,13 +23,13 @@ export class S3Driver implements StorageDriver {
|
|||||||
private bucketName: string;
|
private bucketName: string;
|
||||||
|
|
||||||
constructor(options: S3DriverOptions) {
|
constructor(options: S3DriverOptions) {
|
||||||
const { bucketName, region, ...s3Options } = options;
|
const { bucketName, region, endpoint, ...s3Options } = options;
|
||||||
|
|
||||||
if (!bucketName || !region) {
|
if (!bucketName || !region) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.s3Client = new S3({ ...s3Options, region });
|
this.s3Client = new S3({ ...s3Options, region, endpoint });
|
||||||
this.bucketName = bucketName;
|
this.bucketName = bucketName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,12 +34,14 @@ const fileStorageModuleFactory = async (
|
|||||||
}
|
}
|
||||||
case StorageType.S3: {
|
case StorageType.S3: {
|
||||||
const bucketName = environmentService.getStorageS3Name();
|
const bucketName = environmentService.getStorageS3Name();
|
||||||
|
const endpoint = environmentService.getStorageS3Endpoint();
|
||||||
const region = environmentService.getStorageS3Region();
|
const region = environmentService.getStorageS3Region();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: StorageType.S3,
|
type: StorageType.S3,
|
||||||
options: {
|
options: {
|
||||||
bucketName: bucketName ?? '',
|
bucketName: bucketName ?? '',
|
||||||
|
endpoint: endpoint,
|
||||||
credentials: fromNodeProviderChain({
|
credentials: fromNodeProviderChain({
|
||||||
clientConfig: { region },
|
clientConfig: { region },
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user