From 51ba6dd49540e6097bc2ad195c282dfce632287e Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Fri, 17 Mar 2023 12:18:30 +0800 Subject: [PATCH] @uppy/companion: add S3 prefix env variable (#4320) * Adds optional COMPANION_S3_PREFIX for companion * Fixing prefix usage * fix implementation * add docs --------- Co-authored-by: Will Wilson --- KUBERNETES.md | 1 + env_example | 1 + src/standalone/helper.js | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/KUBERNETES.md b/KUBERNETES.md index e1f36ee44e..ef7643119b 100644 --- a/KUBERNETES.md +++ b/KUBERNETES.md @@ -41,6 +41,7 @@ data: COMPANION_AWS_SECRET: "YOUR AWS SECRET" COMPANION_AWS_BUCKET: "YOUR AWS S3 BUCKET" COMPANION_AWS_REGION: "AWS REGION" + COMPANION_AWS_PREFIX: "AWS PREFIX" COMPANION_OAUTH_DOMAIN: "sub.domain.com" COMPANION_UPLOAD_URLS: "http://tusd.tusdemo.net/files/,https://tusd.tusdemo.net/files/" kind: Secret diff --git a/env_example b/env_example index fe4b1aac30..89e7b2298f 100644 --- a/env_example +++ b/env_example @@ -38,6 +38,7 @@ COMPANION_AWS_SECRET_FILE= COMPANION_AWS_BUCKET= COMPANION_AWS_ENDPOINT= COMPANION_AWS_REGION= +COMPANION_AWS_PREFIX= COMPANION_ZOOM_KEY= COMPANION_ZOOM_SECRET= diff --git a/src/standalone/helper.js b/src/standalone/helper.js index 4b90eda6a0..afe95b39fd 100644 --- a/src/standalone/helper.js +++ b/src/standalone/helper.js @@ -53,6 +53,15 @@ function getCorsOrigins () { return undefined } +const s3Prefix = process.env.COMPANION_AWS_PREFIX || '' + +/** + * Default getKey for Companion standalone variant + * + * @returns {string} + */ +const defaultStandaloneGetKey = (...args) => `${s3Prefix}${utils.defaultGetKey(...args)}` + /** * Loads the config from environment variables * @@ -107,7 +116,7 @@ const getConfigFromEnv = () => { }, s3: { key: process.env.COMPANION_AWS_KEY, - getKey: utils.defaultGetKey, + getKey: defaultStandaloneGetKey, secret: getSecret('COMPANION_AWS_SECRET'), bucket: process.env.COMPANION_AWS_BUCKET, endpoint: process.env.COMPANION_AWS_ENDPOINT,