mirror of
https://github.com/laosb/ghos3.git
synced 2025-04-30 23:51:08 +00:00
fix: Type check.
This commit is contained in:
parent
6eabf8514e
commit
c43ec45a33
1 changed files with 14 additions and 7 deletions
21
src/index.ts
21
src/index.ts
|
@ -1,4 +1,9 @@
|
||||||
import { S3, type S3ClientConfig } from '@aws-sdk/client-s3'
|
import {
|
||||||
|
type PutObjectCommandInput,
|
||||||
|
type S3ClientConfig,
|
||||||
|
type ObjectCannedACL,
|
||||||
|
S3,
|
||||||
|
} from '@aws-sdk/client-s3'
|
||||||
import StorageBase, { type ReadOptions, type Image } from 'ghost-storage-base'
|
import StorageBase, { type ReadOptions, type Image } from 'ghost-storage-base'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { readFile } from 'fs/promises'
|
import { readFile } from 'fs/promises'
|
||||||
|
@ -31,7 +36,7 @@ class S3Storage extends StorageBase {
|
||||||
pathPrefix: string
|
pathPrefix: string
|
||||||
endpoint: string
|
endpoint: string
|
||||||
forcePathStyle: boolean
|
forcePathStyle: boolean
|
||||||
acl: string
|
acl?: ObjectCannedACL
|
||||||
|
|
||||||
constructor(config: Config = {}) {
|
constructor(config: Config = {}) {
|
||||||
super()
|
super()
|
||||||
|
@ -73,7 +78,9 @@ class S3Storage extends StorageBase {
|
||||||
Boolean(process.env.GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE) ||
|
Boolean(process.env.GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE) ||
|
||||||
Boolean(forcePathStyle) ||
|
Boolean(forcePathStyle) ||
|
||||||
false
|
false
|
||||||
this.acl = process.env.GHOST_STORAGE_ADAPTER_S3_ACL || acl || 'public-read'
|
this.acl = (process.env.GHOST_STORAGE_ADAPTER_S3_ACL ||
|
||||||
|
acl ||
|
||||||
|
'public-read') as ObjectCannedACL
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(fileName: string, targetDir?: string) {
|
async delete(fileName: string, targetDir?: string) {
|
||||||
|
@ -126,9 +133,9 @@ class S3Storage extends StorageBase {
|
||||||
|
|
||||||
// Doesn't seem to be documented, but required for using this adapter for other media file types.
|
// Doesn't seem to be documented, but required for using this adapter for other media file types.
|
||||||
// Seealso: https://github.com/laosb/ghos3/pull/6
|
// Seealso: https://github.com/laosb/ghos3/pull/6
|
||||||
urlToPath(url) {
|
urlToPath(url: string) {
|
||||||
const parsedUrl = new URL(url);
|
const parsedUrl = new URL(url)
|
||||||
return parsedUrl.pathname;
|
return parsedUrl.pathname
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(image: Image, targetDir?: string) {
|
async save(image: Image, targetDir?: string) {
|
||||||
|
@ -139,7 +146,7 @@ class S3Storage extends StorageBase {
|
||||||
readFile(image.path),
|
readFile(image.path),
|
||||||
])
|
])
|
||||||
|
|
||||||
let config = {
|
let config: PutObjectCommandInput = {
|
||||||
ACL: this.acl,
|
ACL: this.acl,
|
||||||
Body: file,
|
Body: file,
|
||||||
Bucket: this.bucket,
|
Bucket: this.bucket,
|
||||||
|
|
Loading…
Add table
Reference in a new issue