diff --git a/src/core/config.ts b/src/core/config.ts index dacae058..2e0daed5 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -53,6 +53,8 @@ export const config = { region: process.env.AWS_REGION, // binary files download host address. downloadUrl: process.env.AWS_DOWNLOAD_URL || process.env.DOWNLOAD_URL, + endpoint: process.env.S3_ENDPOINT, // optional - needed when working with S3-compatible services + forcePathStyle: toBool(process.env.S3_FORCE_PATH_STYLE), // optional - some S3 compatible services require path-style addressing }, // Config for Aliyun OSS (https://www.aliyun.com/product/oss) when storageType value is "oss". oss: { diff --git a/src/core/utils/storage.ts b/src/core/utils/storage.ts index 9f2c1af6..10639655 100644 --- a/src/core/utils/storage.ts +++ b/src/core/utils/storage.ts @@ -84,7 +84,10 @@ function uploadFileToS3(key: string, filePath: string, logger: Logger): Promise< sessionToken: _.get(config, 's3.sessionToken'), region: _.get(config, 's3.region'), }); - const s3 = new AWS.S3(); + const s3 = new AWS.S3({ + endpoint: _.get(config, 's3.endpoint'), + s3ForcePathStyle: _.get(config, 's3.forcePathStyle'), + }); fs.readFile(filePath, (err, data) => { if (err) { reject(new AppError(err));