Загрузка Alamofire возобновляется с начала при потере соединения - PullRequest
0 голосов
/ 29 августа 2018

это моя функция загрузки с alamofire, которую я заметил при потере соединения, например, отключение блока ответа Wi-Fi не даст никаких данных возобновления, каково решение? загрузка не удалась и данные о возобновлении всегда ноль

func StartDownload () {

    let fileUrl = self.getSaveFileUrl(fileName: Data[0] as String)
    let destination: DownloadRequest.DownloadFileDestination = { _, _ in
        return (fileUrl, [.removePreviousFile, .createIntermediateDirectories])
    }

    downloadRequest = Alamofire.download(Data[0] as String , to:destination)

        .downloadProgress { (progress) in


            self.progressCircle.progress = progress.fractionCompleted
          }

        .validate()

        .response { defaultDownloadResponse in

            self.Timeer?.invalidate()

            if  (defaultDownloadResponse.error != nil) || defaultDownloadResponse.resumeData != nil  {
                self.startButton.isHidden = false
                self.pauseButton.isHidden = true
                print("someThing went wrong \(String(describing: defaultDownloadResponse.error))")

                print(defaultDownloadResponse.resumeData as Any)

                if let resumeDataa = defaultDownloadResponse.resumeData {
                    let Resume = CachableData(urll: self.Data[0].lastPathComponent as String, Resume: resumeDataa)
                    self.cacher.persist(item: Resume) { url, error in
                        if let error = error {
                            print("Text failed to persist: \(error)")
                        } else {
                            print("Text persisted in \(url?.absoluteString ?? "m")")
                            return
                        }
                    }

                }
            }


    }
    }
}
...