Skip to content

Commit d207292

Browse files
authored
Merge pull request #165 from timhill1989/Added-Max-Retry-Count
added option to change maxRetryCount on Android devices
2 parents 922ddac + 8d026a9 commit d207292

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/background-http.android.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ class Task extends ObservableBase {
198198
if (autoDeleteAfterUpload) {
199199
request.setAutoDeleteFilesAfterSuccessfulUpload(true);
200200
}
201+
const maxRetryCount = typeof options.androidMaxRetries === "number" ? options.androidMaxRetries : undefined;
202+
if (maxRetryCount) {
203+
request.setMaxRetries(maxRetryCount);
204+
}
201205

202206
const headers = options.headers;
203207
if (headers) {
@@ -269,6 +273,14 @@ class Task extends ObservableBase {
269273
uploadNotificationConfig.setTitleForAllStatuses(notificationTitle);
270274
request.setNotificationConfig(uploadNotificationConfig);
271275
}
276+
const autoDeleteAfterUpload = typeof options.androidAutoDeleteAfterUpload === "boolean" ? options.androidAutoDeleteAfterUpload : false;
277+
if (autoDeleteAfterUpload) {
278+
request.setAutoDeleteFilesAfterSuccessfulUpload(true);
279+
}
280+
const maxRetryCount = typeof options.androidMaxRetries === "number" ? options.androidMaxRetries : undefined;
281+
if (maxRetryCount) {
282+
request.setMaxRetries(maxRetryCount);
283+
}
272284

273285
const headers = options.headers;
274286
if (headers) {

src/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,10 @@ export interface Request {
185185
* Use this to set if files should be deleted automatically after upload
186186
*/
187187
androidAutoDeleteAfterUpload?: boolean;
188+
189+
/*
190+
* Use this to set the maximum retry count. The default retry count is 0
191+
* https://github.com/gotev/android-upload-service/wiki/Recipes#backoff
192+
*/
193+
androidMaxRetries?: number;
188194
}

0 commit comments

Comments
 (0)