Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseURL configuration option to S3 modules #1876

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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