perf(app): throttle upload progress callbacks to 256KB steps
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -139,9 +139,15 @@ class DartHttpTransport implements Transport {
|
||||
final file = File(filePath);
|
||||
final length = await file.length();
|
||||
var sent = 0;
|
||||
var lastReported = 0;
|
||||
// 256KB 步长节流(与原生 UploadPutExecutor 一致);末块必报 sent==length。
|
||||
const progressStep = 256 * 1024;
|
||||
final progressStream = file.openRead().map((List<int> chunk) {
|
||||
sent += chunk.length;
|
||||
onProgress?.call(sent, length);
|
||||
if (sent - lastReported >= progressStep || sent == length) {
|
||||
lastReported = sent;
|
||||
onProgress?.call(sent, length);
|
||||
}
|
||||
return chunk;
|
||||
});
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user