Keep a limit on the the number reupload attempts
This commit is contained in:
parent
10c0a52bf2
commit
3be8ee5299
1 changed files with 9 additions and 4 deletions
|
@ -436,8 +436,12 @@ class FileUploader {
|
|||
return _uploadURLFetchInProgress;
|
||||
}
|
||||
|
||||
Future<String> _putFile(UploadURL uploadURL, io.File file,
|
||||
{int contentLength}) async {
|
||||
Future<String> _putFile(
|
||||
UploadURL uploadURL,
|
||||
io.File file, {
|
||||
int contentLength,
|
||||
int attempt = 1,
|
||||
}) async {
|
||||
final fileSize = contentLength ?? file.lengthSync();
|
||||
final startTime = DateTime.now().millisecondsSinceEpoch;
|
||||
_logger.info(
|
||||
|
@ -461,9 +465,10 @@ class FileUploader {
|
|||
return uploadURL.objectKey;
|
||||
} on DioError catch (e) {
|
||||
if (e.message.startsWith(
|
||||
"HttpException: Content size exceeds specified contentLength.")) {
|
||||
"HttpException: Content size exceeds specified contentLength.") &&
|
||||
attempt == 1) {
|
||||
return _putFile(uploadURL, file,
|
||||
contentLength: file.readAsBytesSync().length);
|
||||
contentLength: file.readAsBytesSync().length, attempt: 2);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue