forked from tus/tus-node-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
132 lines (120 loc) · 3.38 KB
/
index.d.ts
File metadata and controls
132 lines (120 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { EventEmitter } from "events";
import http from 'http';
/**
* arguments of constructor which in class extend DataStore
*/
declare interface DataStoreOptions{
path: string;
namingFunction?: (req : http.IncomingMessage) => string;
relativeLocation?: string;
}
declare interface FileStoreOptions extends DataStoreOptions{
directory?: string;
}
declare interface GCStoreOptions extends DataStoreOptions{
bucket: string;
projectId: string;
keyFilename: string;
}
declare interface S3StoreOptions extends DataStoreOptions{
accessKeyId: string;
secretAccessKey: string;
bucket: string;
tmpDirPrefix: string;
partSize: number;
}
declare class File{
id: string;
upload_length: any;
upload_defer_length: any;
upload_metadata: any;
constructor(file_id: string, upload_length: any, upload_defer_length: any, upload_metadata: any);
}
/**
* Based store for all DataStore classes.
*/
export declare class DataStore extends EventEmitter{
constructor(options : DataStoreOptions);
get extensions() : any;
set extensions(extensions_array : any);
create(req: http.IncomingMessage): Promise<any>;
write(req: http.IncomingMessage, file_id?: string, offset?: number): Promise<any>;
getOffset(id: string): Promise<any>;
}
/**
* file store in local storage
*/
export declare class FileStore extends DataStore{
constructor(options : FileStoreOptions);
create(req: http.IncomingMessage): Promise<any>;
write(req: http.IncomingMessage, file_id?: string, offset?: number): Promise<any>;
getOffset(file_id: string): Promise<any>;
}
/**
* file store in Google Cloud
*/
export declare class GCSDataStore extends DataStore{
constructor(options: GCStoreOptions);
create(req: http.IncomingMessage): Promise<any>;
write(req: http.IncomingMessage, file_id?: string, offset?: number): Promise<any>;
getOffset(file_id: string): Promise<any>;
}
/**
* file store in AWS S3
*/
export declare class S3Store extends DataStore {
constructor(options : S3StoreOptions);
create(req: http.IncomingMessage): Promise<any>;
write(req: http.IncomingMessage, file_id?: string, offset?: number): Promise<any>;
getOffset(file_id: string, with_parts?: boolean): Promise<any>;
}
/**
* Tus protocol server implements
*/
export declare class Server extends EventEmitter{
constructor();
get datastore() : DataStore;
set datastore(store: DataStore);
get(path: string, callback: Function): any;
handle(req: http.IncomingMessage, res: http.ServerResponse): http.ServerResponse;
listen(): http.Server;
}
export declare const EVENTS: {
EVENT_ENDPOINT_CREATED: string;
EVENT_FILE_CREATED: string;
EVENT_UPLOAD_COMPLETE: string;
};
export declare const ERRORS: {
MISSING_OFFSET: {
status_code: number;
body: string;
};
INVALID_CONTENT_TYPE: {
status_code: number;
body: string;
};
FILE_NOT_FOUND: {
status_code: number;
body: string;
};
INVALID_OFFSET: {
status_code: number;
body: string;
};
FILE_NO_LONGER_EXISTS: {
status_code: number;
body: string;
};
INVALID_LENGTH: {
status_code: number;
body: string;
};
UNKNOWN_ERROR: {
status_code: number;
body: string;
};
FILE_WRITE_ERROR: {
status_code: number;
body: string;
};
};