-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathindex.ts
More file actions
20 lines (16 loc) 路 629 Bytes
/
Copy pathindex.ts
File metadata and controls
20 lines (16 loc) 路 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { LocalStorageAdapter } from "./LocalStorageAdapter";
import { S3StorageAdapter } from "./S3StorageAdapter";
export interface IStorageAdapter {
save(key: string, data: Buffer): Promise<string>;
get(key: string): Promise<Buffer>;
delete(key: string): Promise<void>;
}
export function getStorage(): IStorageAdapter {
if (process.env.STORAGE_BACKEND === "s3") {
if (!process.env.S3_BUCKET) {
throw new Error("S3_BUCKET must be set when STORAGE_BACKEND=s3");
}
return new S3StorageAdapter(process.env.S3_BUCKET);
}
return new LocalStorageAdapter("./data");
}