Progress support please
ahmetveysels opened this issue · 2 comments
ahmetveysels commented
we have to see the progress at file upload time. can you support
hellohejinyu commented
int total = file.lengthSync();
Stream<List<int>> fs = file.openRead();
int byteLength = 0;
Stream<List<int>> stream = fs.transform(
StreamTransformer.fromHandlers(
handleData: (data, sink) {
byteLength += data.length;
print('uploading: ${byteLength / total * 100}%');
sink.add(data);
},
handleError: (error, stackTrace, sink) {
sink.close();
},
handleDone: (sink) {
sink.close();
},
),
);You can handle the stream like this in the code above.
jonasfj commented
I think wrapping the stream is a good solution.
I don't think we need a solution for progress reporting in this package.
If someone wants to build a generic solution for making progress bars for streams that sounds like a good idea, but I don't think it belongs in this package. You can just have such a thing return a wrapped stream that you then pass to package:gcloud when uploading.