Alamofire报告在同一请求下下载多个URL时错误下载progress
func test(){
let urls = ["https://www.sample-videos.com/zip/30mb.zip", "https://www.sample-videos.com/zip/30mb.zip", "https://www.sample-videos.com/zip/30mb.zip"].compactMap { URL(string: $0) }
for i in urls{
let destination: DownloadRequest.Destination = { _, _ in
var documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
documentsURL.appendPathComponent("duck.zip")
return (documentsURL, [.removePreviousFile])
}
AF.download(i, to: destination).downloadProgress(closure: { progess in
print(progess.fractionCompleted * 100)
}).responseData { response in
print(response)
}
}
}
印刷值
-0.6780020344008234 0.9387720476319094 0.9909260502781266 1.0430800529243438 0.7301560370470407 1.0952340555705609 1.147380582167781 0.7823100396932579 0.834464042339475 1.1995420608629954 0.8866180449856922 1.2516960635092125 1.3038500661554298 1.3560040688016468 1.408158071447864 1.5124660767402984 1.5646200793865157 1.6167740820327328 0.9387720476319094 0.9909260502781266 1.0430800529243438 1.0952340555705609 1.147380582167781 1.1995420608629954 1.2516960635092125 0.7301560370470407 0.7823100396932579 0.834464042339475 1.66892808467895 1.8253900926176014 1.8775440952638187 0.8866180449856922 1.3038500661554298 1.3560040688016468 0.9909260502781266 1.408158071447864 1.4603120740940814 1.9818521005562533 1.5646200793865157 1.0430800529243438 2.0340061032024703 1.6167740820327328 2.0861601058486876 1.66892808467895 2.1383141084949044 2.1904681111411217 1.7732360899713844 1.0952340555705609 1.8775440952638187 1.147380582167781 1.9296980979100358 2.242622113787339 2.346930119079773 1.1995420608629954 2.0340061032024703 1.2516960635092125 2.503392127018425
func test(){
let urls = ["https://www.sample-videos.com/zip/30mb.zip", "https://www.sample-videos.com/zip/30mb.zip", "https://www.sample-videos.com/zip/30mb.zip"].compactMap { URL(string: $0) }
for i in urls{
let destination: DownloadRequest.Destination = { _, _ in
var documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
documentsURL.appendPathComponent("duck.zip")
return (documentsURL, [.removePreviousFile])
}
AF.download(i, to: destination).downloadProgress(closure: { progess in
print(progess.fractionCompleted * 100)
}).responseData { response in
print(response)
}
}
}
printed values -
0.6780020344008234
0.9387720476319094
0.9909260502781266
1.0430800529243438
0.7301560370470407
1.0952340555705609
1.1473880582167781
0.7823100396932579
0.834464042339475
1.1995420608629954
0.8866180449856922
1.2516960635092125
1.3038500661554298
1.3560040688016468
1.408158071447864
1.5124660767402984
1.5646200793865157
1.6167740820327328
0.9387720476319094
0.9909260502781266
1.0430800529243438
1.0952340555705609
1.1473880582167781
1.1995420608629954
1.2516960635092125
0.7301560370470407
0.7823100396932579
0.834464042339475
1.66892808467895
1.8253900926176014
1.8775440952638187
0.8866180449856922
1.3038500661554298
1.3560040688016468
0.9909260502781266
1.408158071447864
1.4603120740940814
1.9818521005562533
1.5646200793865157
1.0430800529243438
2.0340061032024703
1.6167740820327328
2.0861601058486876
1.66892808467895
2.1383141084949044
2.1904681111411217
1.7732360899713844
1.0952340555705609
1.8775440952638187
1.1473880582167781
1.9296980979100358
2.242622113787339
2.346930119079773
1.1995420608629954
2.0340061032024703
1.2516960635092125
2.503392127018425
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论