-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
I tried to upload a large file by slice and combine them after uploaded. After upload, there should be some functions like move to combine those segments, but I cannot find it.
Here is part of my code to upload.
Future<void> _uploadByChunk(Client davClient) async {
final fileSize = getFileSize(localPath);
final sliceCount = (fileSize / UPLOAD_SLICE_SIZE).ceil();
final f = io.File(localPath);
setStatus(.inProgress);
for (int i = _uploadedSlice ?? 0; i < sliceCount; i++) {
if (_cancelToken?.isCancelled == true) {
print("Upload $id cancelled, stopping chunked upload");
return;
}
final offset = i * UPLOAD_SLICE_SIZE;
final currentChunkSize = (i == sliceCount - 1)
? fileSize - offset
: UPLOAD_SLICE_SIZE;
final sliceStream = await f
.openRead(offset, offset + currentChunkSize)
.toList();
final sliceData = sliceStream.expand((x) => x).toList();
await davClient.write(
"$remotePath.part$i",
Uint8List.fromList(sliceData),
onProgress: (count, total) {
final overallProgress = ((i * UPLOAD_SLICE_SIZE) + count) / fileSize;
setProgress((overallProgress * fileSize).toInt(), fileSize);
},
cancelToken: _cancelToken,
);
_uploadedSlice = i + 1;
}
}Metadata
Metadata
Assignees
Labels
No labels