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

S3 upload custom endpoint url #244

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

peppelauro
Copy link

Description

Allow to use also a non-Amazon S3 provider like OVH, DigitalOcean and so on

Contributor Checklist

Make sure to do the following steps if they are applicable to your PR:

Add endpoint param to the call to enable custom endpoint
Copy link
Collaborator

@vincanger vincanger left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution here @peppelauro. What happens if the user wants to use Amazon S3 and not a custom endpoint or 3rd-party provider? Could this possible be confusing for them? Shouldn't we add some comments in the files or docs to explain what's going on? What do you think?

@peppelauro
Copy link
Author

@vincanger good observation, what if we check the existence of the env AWS_S3_ENDPOINT_URL?

If it doesn't exists then use S3Client as usual (amazon default, no endpoint required), else use it in the client, something like follow:

let conf = {
  region: process.env.AWS_S3_REGION,
  credentials: {
    accessKeyId: process.env.AWS_S3_IAM_ACCESS_KEY!,
    secretAccessKey: process.env.AWS_S3_IAM_SECRET_KEY!,
  },
}

if ("AWS_S3_ENDPOINT_URL" in process.env) {
    conf.endpoint = process.env.AWS_S3_ENDPOINT_URL,
}

const s3Client = new S3Client(conf);

@peppelauro
Copy link
Author

And of course, in case you validate the previous snippet, we will add a commented line in the .env.server:

`

(OPTIONAL) get your aws s3 credentials at https://console.aws.amazon.com and create a new IAM user with S3 access

#If you want to use a non-amazon S3 decomment the following line:
#AWS_S3_ENDPOINT_URL=https://...
AWS_S3_IAM_ACCESS_KEY=ACK...
AWS_S3_IAM_SECRET_KEY=t+33a...
AWS_S3_FILES_BUCKET=your-bucket-name
AWS_S3_REGION=your-region
`

@vincanger
Copy link
Collaborator

@peppelauro on second thought, I think it's too confusing to add the conditional code and optional env variable to the template. I think it's best if we don't clutter it too much. We can only offer so many integrations and examples for the user, so if the user wants to use something else besides AWS S3, that's up to them to figure out how to integrate it.

With that said, what do you think about adding a section to the "File Upload" docs, e.g. "Using a non-Amazon S3 provider (OVH, DigitalOcean)" that includes this information and code snippet?

@peppelauro
Copy link
Author

@peppelauro on second thought, I think it's too confusing to add the conditional code and optional env variable to the template. I think it's best if we don't clutter it too much. We can only offer so many integrations and examples for the user, so if the user wants to use something else besides AWS S3, that's up to them to figure out how to integrate it.

With that said, what do you think about adding a section to the "File Upload" docs, e.g. "Using a non-Amazon S3 provider (OVH, DigitalOcean)" that includes this information and code snippet?

I understand but the user will have to modify the source code to enable that feature is it?

No problem, I will specify with an "how to" into the doc :)

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

Successfully merging this pull request may close these issues.

2 participants