fix: Code style & add type.

This commit is contained in:
Shibo Lyu 2023-12-17 21:57:33 +08:00
parent ea68ac43b5
commit 4ae5e6b7de

View file

@ -68,9 +68,9 @@ class S3Storage extends StorageBase {
Boolean(forcePathStyle) || Boolean(forcePathStyle) ||
false false
let defaultHost; let defaultHost: string
if(this.forcePathStyle) { if (this.forcePathStyle) {
defaultHost = `https://s3${ 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}`
@ -82,7 +82,8 @@ class S3Storage extends StorageBase {
this.host = this.host =
process.env.GHOST_STORAGE_ADAPTER_S3_ASSET_HOST || process.env.GHOST_STORAGE_ADAPTER_S3_ASSET_HOST ||
assetHost || defaultHost 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 || ''
@ -152,7 +153,7 @@ class S3Storage extends StorageBase {
async save(image: Image, targetDir?: string) { async save(image: Image, targetDir?: string) {
const directory = targetDir || this.getTargetDir(this.pathPrefix) const directory = targetDir || this.getTargetDir(this.pathPrefix)
const fileName = await this.getUniqueFileName(image, directory); const fileName = await this.getUniqueFileName(image, directory)
const file = createReadStream(image.path) const file = createReadStream(image.path)
let config: PutObjectCommandInput = { let config: PutObjectCommandInput = {