1 | import { Readable, Writable } from 'stream';
|
2 | import { BucketFile, BucketType } from './types';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export interface Driver<F = any> {
|
8 | type: BucketType;
|
9 | name: string;
|
10 |
|
11 | toFile(orgFile: F): Omit<BucketFile, 'bucket'>;
|
12 |
|
13 |
|
14 | getPath(obj: F): string;
|
15 |
|
16 | exists(path: string): Promise<boolean>;
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 | getCloudFile(path: String): Promise<F | null>;
|
23 |
|
24 | listCloudFiles(opts: ListCloudFilesOptions): Promise<F[]>;
|
25 |
|
26 | downloadCloudFile(cf: F, localPath: string): Promise<void>;
|
27 |
|
28 | uploadCloudFile(localFilePath: string, remoteFilePath: string, contentType?: string): Promise<F>;
|
29 |
|
30 | copyCloudFile(cf: F, destDir: BucketFile): Promise<void>;
|
31 |
|
32 | deleteCloudFile(path: string): Promise<boolean>;
|
33 |
|
34 | downloadAsText(path: string): Promise<string>
|
35 |
|
36 | uploadCloudContent(path: string, content: string, contentType?: string): Promise<void>;
|
37 |
|
38 | createReadStream(path: string): Promise<Readable>;
|
39 |
|
40 | createWriteStream(path: string): Promise<Writable>;
|
41 |
|
42 | }
|
43 |
|
44 |
|
45 | export interface ListCloudFilesOptions {
|
46 | prefix?: string;
|
47 | glob?: string;
|
48 | delimiter?: boolean;
|
49 | }
|