fileUpload method
Future<HttpData>
fileUpload({
- MultipartFile? multipartFile,
- String? url,
- String filePath = "",
- String key = 'file',
- String? fileName,
- String? method,
- FormData? formData,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
- Function? onStart,
- Function? onError,
- Function? onFinish,
- dynamic handleRes(
- dynamic map
- bool publicMethod = false,
-----------------------------------------上传文件方法封装-------------------------------------------------------------
Implementation
Future<HttpData> fileUpload({
MultipartFile? multipartFile,
String? url,
String filePath = "",
String key = 'file',
String? fileName,
String? method,
FormData? formData,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
Function? onStart,
Function? onError,
Function? onFinish,
dynamic Function(dynamic map)? handleRes,
bool publicMethod = false
}) async{
MultipartFile file = multipartFile??await MultipartFile.fromFile(filePath, filename: fileName);
return await request(
url: url,
method: method ?? Method.post,
publicMethod: publicMethod,
data: formData ?? FormData.fromMap({
key: file
}),
onSendProgress: (int sent, int total){
onSendProgress?.call(sent, total);
},
onReceiveProgress: (int sent, int total){
onReceiveProgress?.call(sent, total);
},
handleRes: handleRes
);
}