diff --git a/website/modules/@apostrophecms/uploadfs/index.js b/website/modules/@apostrophecms/uploadfs/index.js index 38898a73..2f64441b 100644 --- a/website/modules/@apostrophecms/uploadfs/index.js +++ b/website/modules/@apostrophecms/uploadfs/index.js @@ -1,24 +1,29 @@ const { getEnv } = require('../../../utils/env'); +const aposS3Secret = process.env.APOS_S3_SECRET; +const aposS3Https = getEnv('APOS_S3_HTTPS'); + +const uploadfsOptions = { + storage: 's3', + bucket: getEnv('APOS_S3_BUCKET'), + region: getEnv('APOS_S3_REGION'), + endpoint: getEnv('APOS_S3_ENDPOINT'), + style: getEnv('APOS_S3_STYLE'), + https: aposS3Https.toLowerCase() === 'true', + cdn: { + enabled: true, + url: getEnv('APOS_CDN_URL'), + }, +}; + +if (aposS3Secret) { + uploadfsOptions.secret = aposS3Secret; + uploadfsOptions.key = getEnv('APOS_S3_KEY'); +} + const res = { options: { - uploadfs: { - storage: 's3', - // Get your credentials at aws.amazon.com - secret: getEnv('APOS_S3_SECRET'), - key: getEnv('APOS_S3_KEY'), - // Bucket name created on aws.amazon.com - bucket: getEnv('APOS_S3_BUCKET'), - // Region name for endpoint - region: getEnv('APOS_S3_REGION'), - endpoint: getEnv('APOS_S3_ENDPOINT'), - style: getEnv('APOS_S3_STYLE'), - https: getEnv('APOS_S3_HTTPS'), - cdn: { - enabled: true, - url: getEnv('APOS_CDN_URL'), - }, - }, + uploadfs: uploadfsOptions, }, };