mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Fix media code, clean up old types
This commit is contained in:
parent
852efaea50
commit
0e4d6b401c
34 changed files with 137 additions and 1204 deletions
|
|
@ -4,8 +4,8 @@ import { MediaBackend, MediaBackendType, MediaHasher } from "..";
|
|||
import type { ConfigType } from "config-manager";
|
||||
|
||||
export class LocalMediaBackend extends MediaBackend {
|
||||
constructor(private config: ConfigType) {
|
||||
super(MediaBackendType.LOCAL);
|
||||
constructor(config: ConfigType) {
|
||||
super(config, MediaBackendType.LOCAL);
|
||||
}
|
||||
|
||||
public async addFile(file: File) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import type { ConfigType } from "config-manager";
|
|||
|
||||
export class S3MediaBackend extends MediaBackend {
|
||||
constructor(
|
||||
private config: ConfigType,
|
||||
config: ConfigType,
|
||||
private s3Client = new S3Client({
|
||||
endPoint: config.s3.endpoint,
|
||||
useSSL: true,
|
||||
|
|
@ -16,7 +16,7 @@ export class S3MediaBackend extends MediaBackend {
|
|||
secretKey: config.s3.secret_access_key,
|
||||
})
|
||||
) {
|
||||
super(MediaBackendType.S3);
|
||||
super(config, MediaBackendType.S3);
|
||||
}
|
||||
|
||||
public async addFile(file: File) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ export class MediaHasher {
|
|||
}
|
||||
|
||||
export class MediaBackend {
|
||||
constructor(private backend: MediaBackendType) {}
|
||||
constructor(
|
||||
public config: ConfigType,
|
||||
public backend: MediaBackendType
|
||||
) {}
|
||||
|
||||
public getBackendType() {
|
||||
return this.backend;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ describe("MediaBackend", () => {
|
|||
let mockConfig: ConfigType;
|
||||
|
||||
beforeEach(() => {
|
||||
mediaBackend = new MediaBackend(MediaBackendType.S3);
|
||||
mockConfig = {
|
||||
media: {
|
||||
conversion: {
|
||||
|
|
@ -24,6 +23,7 @@ describe("MediaBackend", () => {
|
|||
},
|
||||
},
|
||||
} as ConfigType;
|
||||
mediaBackend = new MediaBackend(mockConfig, MediaBackendType.S3);
|
||||
});
|
||||
|
||||
it("should initialize with correct backend type", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue