通常我使用Alamofire & Moya/RxSwift & ObjectMapper来分析对象,但现在添加了一个需求。我的应用需要下载文件。
我有用处
Alamofire.download(urlString, to: destination) 暂时解决了问题
但这并不优雅。
我想使用Moya来维护相同的网络层。
你能显示一个下载Moya的"TargetType“吗?
发布于 2017-07-27 16:56:15
要使用Moya下载文件,关键是要覆盖`
var task:Task{
switch self {
case .download:
return .download(DownloadType.request(DefaultDownloadDestination))
}
}https://gist.github.com/pandaApe/fac2615f729c9a0cf6bab29700416747
发布于 2018-11-12 17:10:23
@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)https://stackoverflow.com/questions/44237231
复制相似问题