uppy icon indicating copy to clipboard operation
uppy copied to clipboard

add COMPANION_AWS_FORCE_PATH_STYLE support

Open nadeemc opened this issue 2 years ago • 3 comments

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

nadeemc avatar Apr 09 '24 18:04 nadeemc

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 d42c91c..878b711 100644
--- a/packages/@uppy/companion/lib/standalone/helper.js
+++ b/packages/@uppy/companion/lib/standalone/helper.js
@@ -124,6 +124,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,

github-actions[bot] avatar Apr 09 '24 18:04 github-actions[bot]

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

mifi avatar Apr 16 '24 20:04 mifi

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

The docs now live in uppy, not uppy.io

Murderlon avatar Apr 17 '24 09:04 Murderlon

i believe this was merged prematurely

mifi avatar Jul 03 '24 12:07 mifi