refactor(server): separate s3 & r2 storage to plugin (#5805)

This commit is contained in:
liuyi
2024-02-05 15:10:09 +00:00
parent 25e8a2a22f
commit 296d47f102
16 changed files with 201 additions and 92 deletions

View File

@@ -6,15 +6,18 @@ import type {
PutObjectMetadata,
StorageProvider,
} from '../../../fundamentals';
import { Config, createStorageProvider, OnEvent } from '../../../fundamentals';
import { Config, OnEvent, StorageProviderFactory } from '../../../fundamentals';
@Injectable()
export class AvatarStorage {
public readonly provider: StorageProvider;
private readonly storageConfig: Config['storage']['storages']['avatar'];
constructor(private readonly config: Config) {
this.provider = createStorageProvider(this.config.storage, 'avatar');
constructor(
private readonly config: Config,
private readonly storageFactory: StorageProviderFactory
) {
this.provider = this.storageFactory.create('avatar');
this.storageConfig = this.config.storage.storages.avatar;
}

View File

@@ -6,10 +6,9 @@ import type {
StorageProvider,
} from '../../../fundamentals';
import {
Config,
createStorageProvider,
EventEmitter,
OnEvent,
StorageProviderFactory,
} from '../../../fundamentals';
@Injectable()
@@ -18,9 +17,9 @@ export class WorkspaceBlobStorage {
constructor(
private readonly event: EventEmitter,
private readonly config: Config
private readonly storageFactory: StorageProviderFactory
) {
this.provider = createStorageProvider(this.config.storage, 'blob');
this.provider = this.storageFactory.create('blob');
}
async put(workspaceId: string, key: string, blob: BlobInputType) {