-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
index.d.ts
212 lines (182 loc) · 5.66 KB
/
index.d.ts
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import * as observable from "tns-core-modules/data/observable";
/**
* Get or create a background download/upload session by id.
* @param id The session id.
*/
export function session(id: string): Session;
/**
* Provides error information for error notifications.
*/
export interface ErrorEventData extends observable.EventData {
/**
* Provides the underlying error. The value is platform specific.
*/
error: any /*NSError | java.lang.Exception*/;
/** HTTP response code if response object is present, otherwise -1 */
responseCode: number;
// The response from server
response: any; // net.gotev.uploadservice.ServerResponse
}
/**
* Provides the current and total bytes of long running transfer tasks.
*/
export interface ProgressEventData extends observable.EventData {
/**
* The bytes transfered so far.
*/
currentBytes: number;
/**
* The expected bytes to transfer.
*/
totalBytes: number;
}
/**
* Provides the server response.
*/
export interface ResultEventData extends observable.EventData {
/**
* The string response of the server.
*/
data: string;
/** HTTP response code if response object is present, otherwise -1 */
responseCode: number;
}
export interface CompleteEventData extends observable.EventData {
/** HTTP response code if response object is present, otherwise -1 */
responseCode: number;
/** Currently available for Android only */
response?: any; // net.gotev.uploadservice.ServerResponse
}
/**
* Encapsulates some information for background http transfers.
*/
export interface Task {
/**
* Get the description of the task, that was provided during the task creation.
*/
description: string;
/**
* Gets the current count of uploaded bytes. (read-only)
*/
upload: number;
/**
* Gets the expected total count of bytes to upload. (read-only)
*/
totalUpload: number;
/**
* Gets the status of the background upload task.
* Possible states: "panding" | "uploading" | "error" | "complete".
* (read-only)
*/
status: string;
/**
* Cancel the Upload Task.
*/
cancel(): void;
/**
* Subscribe for a general event.
* @param event The name of the event to subscribe for.
* @param handler The handler called when the event occure.
* @event
*/
on(event: string, handler: (e: observable.EventData) => void): void;
/**
* Subscribe for error notifications.
* @param event
* @param handler A handler that will receive the error details
* @event
*/
on(event: "error", handler: (e: ErrorEventData) => void): void;
/**
* Subscribe for progress notifications.
* @param event
* @param handler A handler that will receive a progress event with the current and expected total bytes
* @event
*/
on(event: "progress", handler: (e: ProgressEventData) => void): void;
/**
* Upon successful upload provides the server response.
* @param event
* @param handler A handler that will receive the response event.
* @event
*/
on(event: "responded", handler: (e: ResultEventData) => void): void;
/**
* Subscribe for the success notification.
* @param event
* @param handler A function that will be called with general event data upon successful completion
* @event
*/
on(event: "complete", handler: (e: observable.EventData) => void): void;
}
/**
* Groups background http tasks in sessions, used to initiate background transfers.
*/
export interface Session {
/**
* Initiate a new background file upload task.
* @param fileUri A file path to upload.
* @param options Options for the upload, sets uri, headers, task description etc.
*/
uploadFile(fileUri: string, options: Request): Task;
multipartUpload(params: Array<any>, options: Request): Task;
}
/**
* Encapsulates the information required to initiate new background transfers.
*/
export interface Request {
/**
* Gets or sets the request url.
*/
url: string;
/**
* Gets or set the HTTP method.
* By default 'GET' will be used.
*/
method?: string;
/**
* Specify additional HTTP headers.
*/
headers?: {};
/**
* Use this to help you identify the task.
* Sets the task's description property.
* You can store serialized JSON object.
*/
description: string;
/**
* Use utf8 encode in requests
*/
utf8?: boolean;
/*
* Use this to set if progress notification should be displayed or not.
* Please note that since API26, Android requires developers to use notifications
* when running background tasks. https://developer.android.com/about/versions/oreo/background
*/
androidDisplayNotificationProgress?: boolean;
/*
* Use this to set the title shown in the Android notifications center.
*/
androidNotificationTitle?: string;
/*
* Use this to set if files should be deleted automatically after upload
*/
androidAutoDeleteAfterUpload?: boolean;
/*
* Use this to set the maximum retry count. The default retry count is 0
* https://github.com/gotev/android-upload-service/wiki/Recipes#backoff
*/
androidMaxRetries?: number;
/*
* Use this to set if notifications should be cleared automatically upon upload completion
*/
androidAutoClearNotification?: boolean;
/*
* Use this to set if a ringtone should be played upon upload completion
*/
androidRingToneEnabled?: boolean;
/*
* Use this to set the channel ID for the notifications
*/
androidNotificationChannelID?: string;
}