uploadUri<T> method
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),
文件上传 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);
}