DioError [DioErrorType.RESPONSE]:将空文件发送到dio的multipartFile时,Http状态错误[500]

时间:2020-07-12 11:26:25

标签: flutter dart multipartform-data dio

如果没有文件要多部分发送,该如何处理!?

这是我的代码:

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;
    }
  }

0 个答案:

没有答案