uploadUri<T> method

Future<BasicModel> uploadUri<T>(
  1. Uri uri,
  2. Object? data, {
  3. dynamic onSendProgress,
  4. dynamic onReceiveProgress,
  5. bool? loading,
  6. dynamic options,
  7. dynamic tag,
  8. dynamic cancelToken,
  9. Duration receiveTimeout = const Duration(seconds: 40),
  10. Duration sendTimeout = const Duration(seconds: 40),
})

文件上传 File upload

Implementation

Future<BasicModel> uploadUri<T>(Uri uri, Object? data,
    {ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
    bool? loading,
    Options? options,
    dynamic tag,
    CancelToken? cancelToken,
    Duration receiveTimeout = const Duration(seconds: 40),
    Duration sendTimeout = const Duration(seconds: 40)}) async {
  assert(_singleton != null, '请先调用 initialize');
  if (hasNetWork) return notNetWorkModel;
  _addLoading(loading);
  uri = basicDioOptions.extraUri?.call(uri) ?? uri;
  final res = await dio.postUri<T>(uri,
      data: basicDioOptions.extraUriData?.call(uri, data) ?? data,
      options: _initBasicOptions(options, uri.path)
          .copyWith(receiveTimeout: receiveTimeout, sendTimeout: sendTimeout),
      onReceiveProgress: onReceiveProgress,
      cancelToken: cancelToken,
      onSendProgress: onSendProgress);
  return _response(res, tag);
}