diff --git a/server/modules/storage/s3/common.js b/server/modules/storage/s3/common.js index 69240914..66068c4b 100644 --- a/server/modules/storage/s3/common.js +++ b/server/modules/storage/s3/common.js @@ -31,17 +31,35 @@ module.exports = class S3CompatibleStorage { } async init() { WIKI.logger.info(`(STORAGE/${this.storageName}) Initializing...`) - const { accessKeyId, secretAccessKey, region, bucket, endpoint } = this.config - this.s3 = new S3({ + const { accessKeyId, secretAccessKey, bucket } = this.config + const s3Config = { accessKeyId, secretAccessKey, - region, - endpoint, params: { Bucket: bucket }, apiVersions: '2006-03-01' - }) + } + + if (!_.isNil(this.config.region)) { + s3Config.region = this.config.region + } + if (!_.isNil(this.config.endpoint)) { + s3Config.endpoint = this.config.endpoint + } + if (!_.isNil(this.config.sslEnabled)) { + s3Config.sslEnabled = this.config.sslEnabled + } + if (!_.isNil(this.config.s3ForcePathStyle)) { + s3Config.s3ForcePathStyle = this.config.s3ForcePathStyle + } + if (!_.isNil(this.config.s3BucketEndpoint)) { + s3Config.s3BucketEndpoint = this.config.s3BucketEndpoint + } + + this.s3 = new S3(s3Config) + // determine if a bucket exists and you have permission to access it await this.s3.headBucket().promise() + WIKI.logger.info(`(STORAGE/${this.storageName}) Initialization completed.`) } async created(page) { diff --git a/server/modules/storage/s3generic/definition.yml b/server/modules/storage/s3generic/definition.yml index 2db6eaff..c7dbd1db 100644 --- a/server/modules/storage/s3generic/definition.yml +++ b/server/modules/storage/s3generic/definition.yml @@ -26,12 +26,30 @@ props: title: Access Key ID hint: The Access Key ID. order: 3 - secretAccessKey : + secretAccessKey: type: String title: Access Key Secret hint: The Access Key Secret for the Access Key ID above. sensitive: true order: 4 + sslEnabled: + type: Boolean + title: Use SSL + hint: Whether to enable SSL for requests + default: true + order: 5 + s3ForcePathStyle: + type: Boolean + title: Force Path Style for S3 objects + hint: Whether to force path style URLs for S3 objects. + default: false + order: 6 + s3BucketEndpoint: + type: Boolean + title: Single Bucket Endpoint + hint: Whether the provided endpoint addresses an individual bucket. + default: false + order: 7 actions: - handler: exportAll label: Export All