From c9cfc5956683bf9149f34b46d9f4b7141dd149d1 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Tue, 21 Apr 2020 14:58:02 +0200 Subject: [PATCH] Add a simple example of using env vars in provider config files Signed-off-by: Alexandre Bodin --- docs/3.0.0-beta.x/plugins/upload.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/3.0.0-beta.x/plugins/upload.md b/docs/3.0.0-beta.x/plugins/upload.md index 07bc1b65db..4a2e0b8ccf 100644 --- a/docs/3.0.0-beta.x/plugins/upload.md +++ b/docs/3.0.0-beta.x/plugins/upload.md @@ -328,9 +328,27 @@ To enable the provider, create or edit the file at `./extensions/upload/config/s Make sure to read the provider's `README` to know what are the possible parameters. -::: tip -Some providers may have additional settings such as the AWS S3 needs an API endpoint URL. You can find a list of these for AWS [here](https://docs.aws.amazon.com/general/latest/gr/ses.html) -::: +### Configuration per envrionment + +When configuring your upload provider you might want to change the configuration based on the `NODE_ENV` environment variable or use environment specific credentials. + +You can do so using a `settings.js` file: + +```js +if (process.env.NODE_ENV === 'production') { + module.exports = { + provider: 'providerName', + providerOptions: { + cloud_name: process.env.PROVIDER_CLOUD_NAME, + api_key: process.env.PROVIDER_API_KEY, + api_secret: process.env.PROVIDER_API_SECRET, + }, + }; +} else { + // to use the default local provider you can return an empty configuration + module.exports = {}; +} +``` ## Create providers