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

Conversation

nadeemc
Copy link

@nadeemc nadeemc commented Apr 9, 2024

This adds support for setting the S3 client's forcePathStyle option. That is necessary to use uppy/companion alongside localstack in development environments.

Subdomain based access to localstack S3 buckets is not supported and AWS has not announced a sunset date for path style access yet.

Alternatively, this is also possible via a Dockerfile, e.g:

FROM transloadit/companion:4.13.0

# Insert this configuration before line 70 in /app/lib/server/s3-client.js
# s3ClientOptions.forcePathStyle = true;
RUN sed -i '70is3ClientOptions.forcePathStyle = true;\n' /app/lib/server/s3-client.js

Copy link
Contributor

github-actions bot commented Apr 9, 2024

Diff output files
diff --git a/packages/@uppy/companion/lib/server/s3-client.js b/packages/@uppy/companion/lib/server/s3-client.js
index 7ff225f..9d6827e 100644
--- a/packages/@uppy/companion/lib/server/s3-client.js
+++ b/packages/@uppy/companion/lib/server/s3-client.js
@@ -30,6 +30,7 @@ module.exports = (companionOptions, createPresignedPostMode = false) => {
     /** @type {import('@aws-sdk/client-s3').S3ClientConfig} */
     let s3ClientOptions = {
       region: s3.region,
+      forcePathStyle: Boolean(s3.forcePathStyle),
     };
     if (s3.useAccelerateEndpoint) {
       // https://github.com/transloadit/uppy/issues/4809#issuecomment-1847320742
diff --git a/packages/@uppy/companion/lib/standalone/helper.js b/packages/@uppy/companion/lib/standalone/helper.js
index 9c21b17..d19ef8a 100644
--- a/packages/@uppy/companion/lib/standalone/helper.js
+++ b/packages/@uppy/companion/lib/standalone/helper.js
@@ -118,6 +118,7 @@ const getConfigFromEnv = () => {
       useAccelerateEndpoint: 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,

@@ -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

@mifi
Copy link
Contributor

mifi commented Apr 16, 2024

thanks! do you mind also updating the docs? https://github.com/transloadit/uppy.io

@Murderlon
Copy link
Member

thanks! do you mind also updating the docs? https://github.com/transloadit/uppy.io

The docs now live in uppy, not uppy.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants