mirror of
https://github.com/laosb/ghos3.git
synced 2025-04-30 23:51:08 +00:00
removed bucket path from non-path style config
This commit is contained in:
parent
8034d08948
commit
60c201178e
1 changed files with 19 additions and 8 deletions
27
src/index.ts
27
src/index.ts
|
@ -63,21 +63,32 @@ class S3Storage extends StorageBase {
|
||||||
if (!this.bucket) throw new Error('S3 bucket not specified')
|
if (!this.bucket) throw new Error('S3 bucket not specified')
|
||||||
|
|
||||||
// Optional configurations
|
// Optional configurations
|
||||||
this.host =
|
this.forcePathStyle =
|
||||||
process.env.GHOST_STORAGE_ADAPTER_S3_ASSET_HOST ||
|
Boolean(process.env.GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE) ||
|
||||||
assetHost ||
|
Boolean(forcePathStyle) ||
|
||||||
`https://s3${
|
false
|
||||||
|
|
||||||
|
let defaultHost;
|
||||||
|
|
||||||
|
if(this.forcePathStyle) {
|
||||||
|
defaultHost = `https://s3${
|
||||||
this.region === 'us-east-1' ? '' : `-${this.region}`
|
this.region === 'us-east-1' ? '' : `-${this.region}`
|
||||||
}.amazonaws.com/${this.bucket}`
|
}.amazonaws.com/${this.bucket}`
|
||||||
|
} else {
|
||||||
|
defaultHost = `https://${this.bucket}.s3${
|
||||||
|
this.region === 'us-east-1' ? '' : `-${this.region}`
|
||||||
|
}.amazonaws.com`
|
||||||
|
}
|
||||||
|
|
||||||
|
this.host =
|
||||||
|
process.env.GHOST_STORAGE_ADAPTER_S3_ASSET_HOST ||
|
||||||
|
assetHost || defaultHost
|
||||||
|
|
||||||
this.pathPrefix = stripLeadingSlash(
|
this.pathPrefix = stripLeadingSlash(
|
||||||
process.env.GHOST_STORAGE_ADAPTER_S3_PATH_PREFIX || pathPrefix || ''
|
process.env.GHOST_STORAGE_ADAPTER_S3_PATH_PREFIX || pathPrefix || ''
|
||||||
)
|
)
|
||||||
this.endpoint =
|
this.endpoint =
|
||||||
process.env.GHOST_STORAGE_ADAPTER_S3_ENDPOINT || endpoint || ''
|
process.env.GHOST_STORAGE_ADAPTER_S3_ENDPOINT || endpoint || ''
|
||||||
this.forcePathStyle =
|
|
||||||
Boolean(process.env.GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE) ||
|
|
||||||
Boolean(forcePathStyle) ||
|
|
||||||
false
|
|
||||||
this.acl = (process.env.GHOST_STORAGE_ADAPTER_S3_ACL ||
|
this.acl = (process.env.GHOST_STORAGE_ADAPTER_S3_ACL ||
|
||||||
acl ||
|
acl ||
|
||||||
'public-read') as ObjectCannedACL
|
'public-read') as ObjectCannedACL
|
||||||
|
|
Loading…
Add table
Reference in a new issue