I have tried to upload video on AWS s3 from Flutter Web and video getting uploaded successfully. But it's not showing me progress like how many percentage uploaded.
uploadFile(String url, Uint8List imageBytes) async {
BaseOptions options = new BaseOptions(
contentType: "multipart/form-data",
headers: {
'Access-Control-Allow-Origin': '*',
"Access-Control-Allow-Methods": "POST,GET,DELETE,PUT,OPTIONS",
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Headers": "Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale",
'Accept': "*/*",
},
connectTimeout: 200000,
receiveTimeout: 200000,
sendTimeout: 200000,
followRedirects: true,
validateStatus: (status) {
print('Status: $status');
return status <= 500;
});
Dio _dio = new Dio(options);
var file = MultipartFile.fromBytes(imageBytes).finalize();
await _dio.put(
url,
data: file,
onReceiveProgress: (int sentBytes, int totalBytes) {
double progressPercent = sentBytes / totalBytes * 100;
print("Progress: $progressPercent %");
if (progressPercent == 100) {
dispose();
}
},
onSendProgress: (int sentBytes, int totalBytes) {
double progressPercent = sentBytes / totalBytes * 100;
print("Progress: $progressPercent %");
if (progressPercent == 100) {
dispose();
}
},
).then((value) {
print("response: ${value.data}");
print("%%%%%%");
}).catchError((onError) {
print(onError);
dispose();
});
}
I have printed logs inside the function onSendProgress
and onReceiveProgress
but its not showing me any logs.
Can anyone please help to show progress for uploading video on AWS Server? Do let me know if anyone needs more information.