From 3a45af2e3af4eb5c455750c6f90e6fd7556c3bcd Mon Sep 17 00:00:00 2001 From: WakuwakuP Date: Wed, 10 Jul 2024 17:48:27 +0900 Subject: [PATCH] chore: Add baseURL configuration option to S3 modules Signed-off-by: WakuwakuP --- lib/config/default.js | 3 ++- lib/config/environment.js | 3 ++- lib/imageRouter/s3.js | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/config/default.js b/lib/config/default.js index d276e46eff..3c5687f1ae 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -74,7 +74,8 @@ module.exports = { accessKeyId: undefined, secretAccessKey: undefined, region: undefined, - endpoint: undefined + endpoint: undefined, + baseURL: undefined }, minio: { accessKey: undefined, diff --git a/lib/config/environment.js b/lib/config/environment.js index 70bdd6c35d..53d5341719 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -44,7 +44,8 @@ module.exports = { accessKeyId: process.env.CMD_S3_ACCESS_KEY_ID, secretAccessKey: process.env.CMD_S3_SECRET_ACCESS_KEY, region: process.env.CMD_S3_REGION, - endpoint: process.env.CMD_S3_ENDPOINT + endpoint: process.env.CMD_S3_ENDPOINT, + baseURL: process.env.CMD_S3_BASEURL }, minio: { accessKey: process.env.CMD_MINIO_ACCESS_KEY, diff --git a/lib/imageRouter/s3.js b/lib/imageRouter/s3.js index 3f47df2099..00b4062fd8 100644 --- a/lib/imageRouter/s3.js +++ b/lib/imageRouter/s3.js @@ -57,7 +57,11 @@ exports.uploadImage = function (imagePath, callback) { if (config.s3.endpoint) { s3Endpoint = config.s3.endpoint } - callback(null, `${s3Endpoint}/${config.s3bucket}/${params.Key}`) + if (config.s3.baseURL) { + callback(null, `${config.s3.baseURL}/${params.Key}`) + } else { + callback(null, `${s3Endpoint}/${config.s3bucket}/${params.Key}`) + } }).catch(err => { if (err) { callback(new Error(err), null)