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 COMPANION_AWS_FORCE_PATH_STYLE support #5066

Open
wants to merge 1 commit into
base: main
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ COMPANION_AWS_REGION="AWS REGION"
COMPANION_AWS_PREFIX="OPTIONAL PREFIX"
# to enable S3 Transfer Acceleration (default: false)
# COMPANION_AWS_USE_ACCELERATE_ENDPOINT="false"
# to enable S3 path style uploads (default: false), this is useful for localstack support
# COMPANION_AWS_FORCE_PATH_STYLE="true"
# to set X-Amz-Expires query param in presigned urls (in seconds, default: 800)
# COMPANION_AWS_EXPIRES="800"
# to set a canned ACL for uploaded objects: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
Expand Down
1 change: 1 addition & 0 deletions examples/aws-companion/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const options = {
bucket: process.env.COMPANION_AWS_BUCKET,
region: process.env.COMPANION_AWS_REGION,
endpoint: process.env.COMPANION_AWS_ENDPOINT,
forcePathStyle: process.env.COMPANION_AWS_FORCE_PATH_STYLE === 'true',
},
server: { host: 'localhost:3020' },
filePath: DATA_DIR,
Expand Down
1 change: 1 addition & 0 deletions examples/aws-nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function getS3Client () {
accessKeyId: process.env.COMPANION_AWS_KEY,
secretAccessKey: process.env.COMPANION_AWS_SECRET,
},
forcePathStyle: process.env.COMPANION_AWS_FORCE_PATH_STYLE === 'true',
})
return s3Client
}
Expand Down
2 changes: 2 additions & 0 deletions examples/digitalocean-spaces/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const companion = require('../../packages/@uppy/companion')
* - COMPANION_AWS_KEY - Your access key ID
* - COMPANION_AWS_SECRET - Your secret access key
* - COMPANION_AWS_BUCKET - Your space's name.
* - COMPANION_AWS_FORCE_PATH_STYLE - Indicates if s3ForcePathStyle should be used rather than subdomain for S3 buckets.
*/

if (!process.env.COMPANION_AWS_REGION) throw new Error('Missing Space region, please set the COMPANION_AWS_REGION environment variable (eg. "COMPANION_AWS_REGION=ams3")')
Expand Down Expand Up @@ -43,6 +44,7 @@ const { app: companionApp } = companion.app({
secret: process.env.COMPANION_AWS_SECRET,
bucket: process.env.COMPANION_AWS_BUCKET,
region: process.env.COMPANION_AWS_REGION,
forcePathStyle: process.env.COMPANION_AWS_FORCE_PATH_STYLE === 'true',
},
server: { host },
filePath: DATA_DIR,
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/env_example
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ COMPANION_AWS_BUCKET=
COMPANION_AWS_ENDPOINT=
COMPANION_AWS_REGION=
COMPANION_AWS_PREFIX=
COMPANION_AWS_FORCE_PATH_STYLE="false"

COMPANION_ZOOM_KEY=
COMPANION_ZOOM_SECRET=
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/src/server/s3-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = (companionOptions, createPresignedPostMode = false) => {
/** @type {import('@aws-sdk/client-s3').S3ClientConfig} */
let s3ClientOptions = {
region: s3.region,
forcePathStyle: Boolean(s3.forcePathStyle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to convert it to a boolean?

Suggested change
forcePathStyle: Boolean(s3.forcePathStyle)
forcePathStyle: s3.forcePathStyle

}

if (s3.useAccelerateEndpoint) {
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/companion/src/standalone/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const getConfigFromEnv = () => {
process.env.COMPANION_AWS_USE_ACCELERATE_ENDPOINT === 'true',
expires: parseInt(process.env.COMPANION_AWS_EXPIRES || '800', 10),
acl: process.env.COMPANION_AWS_ACL,
forcePathStyle: process.env.COMPANION_AWS_FORCE_PATH_STYLE === 'true',
},
server: {
host: process.env.COMPANION_DOMAIN,
Expand Down