通常我使用Alamofire
& Moya/RxSwift
&ObjectMapper
来分析对象但现在添加一个需求。我的应用需要下载文件。
我有用
Alamofire.download(urlString, to: destination)
临时解决了问题
但这并不优雅。
我想使用 Moya 来维护相同的网络层。
你能显示一个下载 Moya 的“TargetType”吗
使用Moya下载文件,关键是override`
var task:Task{
switch self {
case .download:
return .download(DownloadType.request(DefaultDownloadDestination))
}
}
https://gist.github.com/pandaApe/fac2615f729c9a0cf6bab29700416747
@Tony,根据当前的 Moya API,您有两个选择。
/// A file download task to a destination.
case downloadDestination(DownloadDestination)
/// A file download task to a destination with extra parameters using the given encoding.
case downloadParameters(parameters: [String: Any], encoding: ParameterEncoding, destination: DownloadDestination)