uploadFile static method

Future<Response> uploadFile(
  1. String path, {
  2. FormData? data,
})

Implementation

static Future<Response> uploadFile(String path ,{FormData? data}) async{
  var options = BaseOptions(
    connectTimeout: 15000,
    receiveTimeout: 15000,
    responseType: ResponseType.plain,
    validateStatus: (status){
      // 不使用http状态码判断状态,使用AdapterInterceptor来处理(适用于标准REST风格)
      return true;
    },
//      baseUrl: Constant.BASE_URL,
//      contentType: ContentType('application', 'x-www-form-urlencoded', charset: 'utf-8'),
  );
  Dio _dioUp = Dio(options);
  Response response = await _dioUp.post(path,data: data);
  print('uploadFile-->response=${response.toString()}');
  return response;
}