如果没有文件要多部分发送,该如何处理!?
这是我的代码:
var dio = Dio();
表单数据
var formData = new FormData.fromMap({
"Set_Amount_Id": setAmountID,
"Match_Status": matchStatus,
"Upload_ScreenShot": matchStatus.contains("win")? await MultipartFile.fromFile(_screenshot):"",
"Uploaded_by": uploadedBy,
});
try {
Response<Map> response = await dio.post(_url, data: formData);
if (response.statusCode == 200) {
return MatchStatusModel.fromJson(response.data);
} else {
throw Exception('Failed to load post');
}
} catch (e) {
print(">>> $e <<<"); *// DioError [DioErrorType.RESPONSE]: Http status error [500]*
return null;
}
}