Skip to content

Commit

Permalink
chore: Add baseURL configuration option to S3 modules
Browse files Browse the repository at this point in the history
Signed-off-by: WakuwakuP <[email protected]>
  • Loading branch information
WakuwakuP committed Jul 10, 2024
1 parent f00df50 commit 3a45af2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ module.exports = {
accessKeyId: undefined,
secretAccessKey: undefined,
region: undefined,
endpoint: undefined
endpoint: undefined,
baseURL: undefined
},
minio: {
accessKey: undefined,
Expand Down
3 changes: 2 additions & 1 deletion lib/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion lib/imageRouter/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a45af2

Please sign in to comment.