mirror of
https://github.com/strapi/strapi.git
synced 2025-09-02 13:23:12 +00:00
Trimmed whitespace for AWS S3 credentials
If you input a name/key to a bucket with a trailing whitespace, it will respect that trailing whitespace but will then fail to find the bucket. To resolve this, added a util function to check if it's a string. If so it will apply the `trim()` function to remove any unwanted whitespace, else it will return `undefined`.
This commit is contained in:
parent
6159fd0d56
commit
c3a989fcd3
@ -10,6 +10,8 @@
|
||||
const _ = require('lodash');
|
||||
const AWS = require('aws-sdk');
|
||||
|
||||
const trimParam = str => typeof str === "string" ? str.trim() : undefined
|
||||
|
||||
module.exports = {
|
||||
provider: 'aws-s3',
|
||||
name: 'Amazon Web Service S3',
|
||||
@ -55,15 +57,15 @@ module.exports = {
|
||||
init: (config) => {
|
||||
// configure AWS S3 bucket connection
|
||||
AWS.config.update({
|
||||
accessKeyId: config.public,
|
||||
secretAccessKey: config.private,
|
||||
accessKeyId: trimParam(config.public),
|
||||
secretAccessKey: trimParam(config.private),
|
||||
region: config.region
|
||||
});
|
||||
|
||||
const S3 = new AWS.S3({
|
||||
apiVersion: '2006-03-01',
|
||||
params: {
|
||||
Bucket: config.bucket
|
||||
Bucket: trimParam(config.bucket)
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user