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

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

nadeemc
Copy link
Contributor

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

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

docs/companion.md Outdated Show resolved Hide resolved
@aduh95 aduh95 merged commit 7c174e8 into transloadit:main Jul 2, 2024
20 checks passed
This was referenced Jul 2, 2024
github-actions bot added a commit that referenced this pull request Jul 2, 2024
| Package                | Version | Package                | Version |
| ---------------------- | ------- | ---------------------- | ------- |
| @uppy/companion        |  4.15.0 | @uppy/drag-drop        |   3.1.1 |
| @uppy/companion-client |   3.8.2 | @uppy/form             |   3.2.2 |
| @uppy/core             |  3.13.1 | uppy                   |  3.27.2 |

- @uppy/form: do not emit `'submit'` event more than once (Merlijn Vos / #5299)
- @uppy/companion: add `s3.forcePathStyle` option (Nadeem Reinhardt / #5066)
- meta: fix broken workflow status badges in README (Alexander Zaytsev / #5298)
- @uppy/core: add `clearUploadedFiles` to type definition (Augustine Smith / #5295)
- @uppy/companion: add `oauthOrigin` option (Antoine du Hamel / #5297)
- meta: add dark-mode Transloadit logo in README (Alexander Zaytsev / #5291)
- docs,@uppy/drag-drop: `uppy.io/docs` - fix typos/broken links (Evgenia Karunus / #5296)
- meta: Bump docker/build-push-action from 6.1.0 to 6.2.0 (dependabot[bot] / #5290)
@mifi
Copy link
Contributor

mifi commented Jul 3, 2024

i believe this was merged prematurely

mifi added a commit that referenced this pull request Jul 3, 2024
@mifi mifi mentioned this pull request Jul 3, 2024
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.

4 participants