如何使用Moya下载文件 [英] How to use Moya to download file
本文介绍了如何使用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
这篇关于如何使用Moya下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文