Upload file to s3 using presigned url
Hello,
Need some help on using dio
"key": signed_url['fields']['key'],
"AWSAccessKeyId": accessKeyId,
"policy": policy,
"signature": signed_url['fields']['signature'],
"file": await MultipartFile.fromFile(path.dirname(filepath),filename: path.basename(filepath),contentType: new MediaType('application', 'x-tar'))
});
try {
var response = await Dio().post('<my bucket>', data: formData);
print (response.statusCode);
}catch (e){
print (e.toString());
}
I am trying this code to upload a file to s3 using presigned url
I am not seeing any exceptions
What am I doing wrong?
I have also tried http variant as well
Appreciate any pointers. I am falling behind on my deliverables
Thanks
Extending this, I am trying to print the response.
Dio dio = new Dio();
var response = await dio.post(_s3Endpoint, data: formData);
var responseBody = response.data;
print(responseBody);
I am not able to get the response data to print. If I put this in a try catch block, I now get a 400 error. I want to get the details of the error.
try{
await Dio().post(_s3Endpoint, data: formData).then((response) {
if (response.statusCode == 200){
print("Uploaded!");
} else {
print ("**** UNABLE TO UPLOAD ****");
}
});
} catch (e) {
print (e.toString());
}
How do I print the response data?
Any update on this please?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.
this stackoverflow answer works for me, put it here for someone else has the similar issue.