Hello I am flutter user. Now I got trouble in making http request upload progress. Well normally used use dio package. But My project is not able to use dio package. Because in AWS S3 specifically in Multipart upload(Over 5GB file), It dio package has some errors. I had talked with aws supporter. And he said, It is better to use flutter http package.
So Please Don't recommend me to use dio package.
Future<String> httpMultipartRequest(String? multipartPresignedURL,
{List? fileBytes}) async {
var client = http.Request('PUT', Uri.parse(multipartPresignedURL!));
client.bodyBytes = await List.from(fileBytes!);
http.StreamedResponse res = await client.send();
res.stream.listen((value) {
//May be This area is for progress.. but cannot get any data.
print(value);
});
return res.headers['etag']!;
}
I found similar question in Stack Overflow Flutter: How to get upload / download progress for http requests
Below is the code I made as link.
Future<String> httpMultipartRequest(String? multipartPresignedURL,
{List? fileBytes}) async {
var client = http.Request('PUT', Uri.parse(multipartPresignedURL!));
client.bodyBytes = await List.from(fileBytes!);
http.StreamedResponse res = await client.send();
res.stream.transform(StreamTransformer.fromHandlers(
handleData: (data, sink) => print(data),
handleDone: (sink) => sink.close(),
));
return res.headers['etag']!;
}
But it doesn't work too. just skip the listening code.
I think my code has already got filebytes so it doesn't make event..? Is it wrong?
And also I found http.MultipartRequest() which contains progress parameter but the news http package doesn't have progress.
Please help me to solve this problem.