upload<T> method
文件上传 File upload
Implementation
Future<BasicModel> upload<T>(String path, 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);
final res = await dio.post<T>(path,
data: basicDioOptions.extraData?.call(path, data) ?? data,
options: _initBasicOptions(options, path)
.copyWith(receiveTimeout: receiveTimeout, sendTimeout: sendTimeout),
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
onSendProgress: onSendProgress);
return _response(res, tag);
}