apiMultipartPost method
Implementation
Future<dynamic> apiMultipartPost(String url, dynamic body, List<String> filePaths) async {
if (this.config != null && this.config.host != null) {
var request = http.MultipartRequest("POST", Uri.parse(this.config.host + url));
String payload;
if (body != null) {
if (body is String)
payload = body;
else if (body is Map)
payload = jsonEncode(body);
else
payload = jsonEncode(body);
// Set payload fields
request.fields["payload"] = payload;
}
for (var path in filePaths) {
request.files.add(await getMultipartFile(path));
}
var res = await request.send();
debug("Multipart response status: ${res.statusCode} stream: ${res.stream.toString()}");
} else {
return Future.error("No vasat configuration or host found");
}
}