downloadFile static method
Future
downloadFile(
- String urlPath,
- String savePath, {
- ProgressCallback? onReceiveProgress,
- Map<String, dynamic>? queryParameters,
- CancelToken? cancelToken,
- bool deleteOnError = true,
- dynamic data,
- Options? options,
})
Implementation
static Future downloadFile(String urlPath,
String savePath, {
ProgressCallback? onReceiveProgress,
Map<String, dynamic>? queryParameters,
CancelToken? cancelToken,
bool deleteOnError = true,
String lengthHeader = Headers.contentLengthHeader,
data,
Options? options,
}) async {
Options requestOptions = options ?? Options();
Response response;
try {
response = await Http().dio.download(urlPath, savePath,
queryParameters: queryParameters,
cancelToken: cancelToken ?? _cancelToken,
data: data,
options: requestOptions,
onReceiveProgress: onReceiveProgress ??
(int count, int total) {
printWithSystemMethod("$count $total");
});
// if (response == null) {
// // return AppException(9999, "服务异常");
// return AppException(9999, VFTextDelegateHelper.textDelegate.n_server_error);
// }
printWithSystemMethod("========能不能拦截住===下载的==method=try=2=========${response}");
return response;
} catch (e) {
printWithSystemMethod("========能不能拦截住===method==4=====拦截器已经转换==$e==");
if (e is DioException) {
return e.error;
}
return e; //appException
}
}