Skip to content

Commit

Permalink
@uppy/companion: add S3 prefix env variable (transloadit#4320)
Browse files Browse the repository at this point in the history
* Adds optional COMPANION_S3_PREFIX for companion

* Fixing prefix usage

* fix implementation

* add docs

---------

Co-authored-by: Will Wilson <will.wilson@asset.tv>
  • Loading branch information
mifi and mojowill authored Mar 17, 2023
1 parent 59888c0 commit 51ba6dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions KUBERNETES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions env_example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
11 changes: 10 additions & 1 deletion src/standalone/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 51ba6dd

Please sign in to comment.