mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 13:50:38 +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 _ = require('lodash');
|
||||||
const AWS = require('aws-sdk');
|
const AWS = require('aws-sdk');
|
||||||
|
|
||||||
|
const trimParam = str => typeof str === "string" ? str.trim() : undefined
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
provider: 'aws-s3',
|
provider: 'aws-s3',
|
||||||
name: 'Amazon Web Service S3',
|
name: 'Amazon Web Service S3',
|
||||||
@ -55,15 +57,15 @@ module.exports = {
|
|||||||
init: (config) => {
|
init: (config) => {
|
||||||
// configure AWS S3 bucket connection
|
// configure AWS S3 bucket connection
|
||||||
AWS.config.update({
|
AWS.config.update({
|
||||||
accessKeyId: config.public,
|
accessKeyId: trimParam(config.public),
|
||||||
secretAccessKey: config.private,
|
secretAccessKey: trimParam(config.private),
|
||||||
region: config.region
|
region: config.region
|
||||||
});
|
});
|
||||||
|
|
||||||
const S3 = new AWS.S3({
|
const S3 = new AWS.S3({
|
||||||
apiVersion: '2006-03-01',
|
apiVersion: '2006-03-01',
|
||||||
params: {
|
params: {
|
||||||
Bucket: config.bucket
|
Bucket: trimParam(config.bucket)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user