From 9613197f5d26efd699a00e322dc12a862ea3417b Mon Sep 17 00:00:00 2001 From: Mathias Merscher Date: Mon, 11 Feb 2019 17:31:45 +0100 Subject: make aws s3 endpoint configurable Signed-off-by: Mathias Merscher --- lib/config/environment.js | 3 ++- lib/web/imageRouter/s3.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/config/environment.js b/lib/config/environment.js index a57fe0db..cdf87871 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -40,7 +40,8 @@ module.exports = { s3: { accessKeyId: process.env.CMD_S3_ACCESS_KEY_ID, secretAccessKey: process.env.CMD_S3_SECRET_ACCESS_KEY, - region: process.env.CMD_S3_REGION + region: process.env.CMD_S3_REGION, + endpoint: process.env.CMD_S3_ENDPOINT }, minio: { accessKey: process.env.CMD_MINIO_ACCESS_KEY, diff --git a/lib/web/imageRouter/s3.js b/lib/web/imageRouter/s3.js index 626fe148..f2a5a5df 100644 --- a/lib/web/imageRouter/s3.js +++ b/lib/web/imageRouter/s3.js @@ -42,7 +42,9 @@ exports.uploadImage = function (imagePath, callback) { } let s3Endpoint = 's3.amazonaws.com' - if (config.s3.region && config.s3.region !== 'us-east-1') { + if (config.s3.endpoint) { + s3Endpoint = config.s3.endpoint + } else if (config.s3.region && config.s3.region !== 'us-east-1') { s3Endpoint = `s3-${config.s3.region}.amazonaws.com` } callback(null, `https://${s3Endpoint}/${config.s3bucket}/${params.Key}`) -- cgit v1.2.3