[mob] Additional check for fileSize for multipart upload
This commit is contained in:
committed by
Neeraj Gupta
parent
1b6dbbc288
commit
7c2ce513df
@@ -250,6 +250,7 @@ class UploadLocksDB {
|
||||
}
|
||||
final row = rows.first;
|
||||
final objectKey = row[_trackUploadTable.columnObjectKey] as String;
|
||||
final encFileSize = row[_trackUploadTable.columnEncryptedFileSize] as int;
|
||||
final partsStatus = await db.query(
|
||||
_partsTable.table,
|
||||
where: '${_partsTable.columnObjectKey} = ?',
|
||||
@@ -285,6 +286,7 @@ class UploadLocksDB {
|
||||
.byName(row[_trackUploadTable.columnStatus] as String),
|
||||
partUploadStatus: partUploadStatus,
|
||||
partETags: partETags,
|
||||
encFileSize: encFileSize,
|
||||
partSize: row[_trackUploadTable.columnPartSize] as int,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class MultipartInfo {
|
||||
final List<bool>? partUploadStatus;
|
||||
final Map<int, String>? partETags;
|
||||
final int? partSize;
|
||||
final int encFileSize;
|
||||
final MultipartUploadURLs urls;
|
||||
final MultipartStatus status;
|
||||
|
||||
@@ -41,6 +42,7 @@ class MultipartInfo {
|
||||
this.partETags,
|
||||
this.partSize,
|
||||
this.status = MultipartStatus.pending,
|
||||
required this.encFileSize,
|
||||
required this.urls,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,10 +148,11 @@ class MultiPartUploader {
|
||||
Future<String> putMultipartFile(
|
||||
MultipartUploadURLs urls,
|
||||
File encryptedFile,
|
||||
int fileSize,
|
||||
) async {
|
||||
// upload individual parts and get their etags
|
||||
final etags = await _uploadParts(
|
||||
MultipartInfo(urls: urls),
|
||||
MultipartInfo(urls: urls, encFileSize: fileSize),
|
||||
encryptedFile,
|
||||
);
|
||||
|
||||
@@ -180,6 +181,11 @@ class MultiPartUploader {
|
||||
}
|
||||
|
||||
final int encFileLength = encryptedFile.lengthSync();
|
||||
if (encFileLength != partInfo.encFileSize) {
|
||||
throw Exception(
|
||||
"File size mismatch. Expected ${partInfo.encFileSize} but got $encFileLength",
|
||||
);
|
||||
}
|
||||
// Start parts upload
|
||||
int count = 0;
|
||||
while (i < partsLength) {
|
||||
|
||||
@@ -685,6 +685,7 @@ class FileUploader {
|
||||
fileObjectKey = await _multiPartUploader.putMultipartFile(
|
||||
fileUploadURLs,
|
||||
encryptedFile,
|
||||
encFileSize,
|
||||
);
|
||||
}
|
||||
// in case of multipart, upload the thumbnail towards the end to avoid
|
||||
|
||||
Reference in New Issue
Block a user