feat: extra options for generic S3 module
This commit is contained in:
parent
e45145986a
commit
ca0708ea75
@ -31,17 +31,35 @@ module.exports = class S3CompatibleStorage {
|
|||||||
}
|
}
|
||||||
async init() {
|
async init() {
|
||||||
WIKI.logger.info(`(STORAGE/${this.storageName}) Initializing...`)
|
WIKI.logger.info(`(STORAGE/${this.storageName}) Initializing...`)
|
||||||
const { accessKeyId, secretAccessKey, region, bucket, endpoint } = this.config
|
const { accessKeyId, secretAccessKey, bucket } = this.config
|
||||||
this.s3 = new S3({
|
const s3Config = {
|
||||||
accessKeyId,
|
accessKeyId,
|
||||||
secretAccessKey,
|
secretAccessKey,
|
||||||
region,
|
|
||||||
endpoint,
|
|
||||||
params: { Bucket: bucket },
|
params: { Bucket: bucket },
|
||||||
apiVersions: '2006-03-01'
|
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
|
// determine if a bucket exists and you have permission to access it
|
||||||
await this.s3.headBucket().promise()
|
await this.s3.headBucket().promise()
|
||||||
|
|
||||||
WIKI.logger.info(`(STORAGE/${this.storageName}) Initialization completed.`)
|
WIKI.logger.info(`(STORAGE/${this.storageName}) Initialization completed.`)
|
||||||
}
|
}
|
||||||
async created(page) {
|
async created(page) {
|
||||||
|
@ -26,12 +26,30 @@ props:
|
|||||||
title: Access Key ID
|
title: Access Key ID
|
||||||
hint: The Access Key ID.
|
hint: The Access Key ID.
|
||||||
order: 3
|
order: 3
|
||||||
secretAccessKey :
|
secretAccessKey:
|
||||||
type: String
|
type: String
|
||||||
title: Access Key Secret
|
title: Access Key Secret
|
||||||
hint: The Access Key Secret for the Access Key ID above.
|
hint: The Access Key Secret for the Access Key ID above.
|
||||||
sensitive: true
|
sensitive: true
|
||||||
order: 4
|
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:
|
actions:
|
||||||
- handler: exportAll
|
- handler: exportAll
|
||||||
label: Export All
|
label: Export All
|
||||||
|
Loading…
Reference in New Issue
Block a user