uploadUri<T> method

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

文件上传 File upload

Implementation

Future<BaseModel> 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 = baseDioOptions.extraUri?.call(uri) ?? uri;
  final res = await dio.postUri<T>(uri,
      data: baseDioOptions.extraUriData?.call(uri, data) ?? data,
      options: (_mergeOptions(options, uri.path) ?? Options())
          .copyWith(receiveTimeout: receiveTimeout, sendTimeout: sendTimeout),
      onReceiveProgress: onReceiveProgress,
      cancelToken: cancelToken,
      onSendProgress: onSendProgress);
  return _response(res, tag);
}