I am uploading a file using MultipartRequest
from package:http
. I am successfully uploading the file but I want to get the progress of the file that is being uploaded. How can I achieve that? My current code looks something like this
Future submitFile(var report, File file) async {
var uri = Uri.parse(endpoint + "v1/reports");
var request = http.MultipartRequest("POST", uri);
await addHeaders(request.headers);
request.fields.addAll(Report.toMap(report));
if (file != null)
request.files.add(await http.MultipartFile.fromPath(
'report_resource',
file.path,
));
String response = "";
await (await request.send()).stream.forEach((message) {
response = response + String.fromCharCodes(message);
});
return response;
}
I searched for the solution, found this. And this post is somehow not similar to what I want to achieve, as he is using different client for the request.
Maybe I am not searching on the right path. Help is appreciated.
Iterable<int> message
insideforEach
loop? – Ecuador