如何使用Moya下载文件
问题描述:
通常我使用Alamofire
& Moya/RxSwift
& ObjectMapper
到分析对象
但是现在增加了需求.我的应用程序需要下载文件.
Usual I use Alamofire
& Moya/RxSwift
& ObjectMapper
to analysis object
But now add a demand. My app need download file.
我已经使用
Alamofire.download(urlString, to: destination)
临时解决了问题
但这并不优雅.
我想使用Moya来维护相同的网络层.
I want use Moya to Maintain the same network layer.
可以显示下载的Moya的"TargetType"
Can you show a Download Moya"s "TargetType"
答
使用Moya下载文件,关键是覆盖 `
to use Moya to download files, the key thing is override `
var task:Task{
switch self {
case .download:
return .download(DownloadType.request(DefaultDownloadDestination))
}
}
https://gist.github.com/pandaApe/fac2615f729c9a0cf6bab29700416747