Previously I created a REST API which was taking a ZIP file and two other parameters as input from the flutter mobile application
var uri = Uri.parse("http://XX.XXX.XX.XX/gatewayapp/userinfo/sendFileToServer/");
var request = http.MultipartRequest('POST', uri);
Map<String, String> headers = {
"Accept": "application/json"
};
//add headers
request.headers.addAll(headers);
request.fields["customerNumber"] = customerNumber;
request.fields['zippassword'] = password;
var file= await http.MultipartFile.fromPath(
'userDetailsFile',
filePath
);
request.files.add(file);
await request.send().then((streamedResponse) async {
....Implemented the business logic on the response which I was getting
}
It was working as per the expectation.
We moved the API from HTTP to HTTPS using Nginx on the AWS server and changed all the GET and POST-call from the mobile application using HTTPClient and HttpClientRequest and it worked as per the expectation.
However, we are not able to do a multipart request using HTTPClient and HttpClientRequest on the API. I tried using httpclient method but no luck. I also tried something which is given on the below link :
Using HTTPClient on Dart lang github
var uri = Uri.parse("https://XX.XXX.XX.XX/gatewayapp/userinfo/sendFileToServer/");
HttpClient client = await CommonController.createHttpClient();
HttpClientRequest request = await client.post( uri.toString() , 443, filePath);
Can anyone please help me move forward in the right direction? Any help would be appreciated! Thanks