I have downloadTask, I'm a trying to download a video using downloadTask but it doesn't seem to work; whenever I download small files likes pictures or small videos it works perfectly but the videos I am now trying to download are really long, I even type the URL Explicitly but it doesn't work. Adding some breakpoints I realized it never gets to the closure, goes directly to the .resume(), but this happens specifically with these long videos. Please help, any ideas? Here's my code
@objc func downloadVideo() {
guard let urlString = lessons[currentLesson].video_url, let videoURL = URL(string: urlString) else { return }
URLSession.shared.downloadTask(with: videoURL) { fileURL, response, error in
if let error = error{
print("error \(error)")
} else {
print("Our local URL = \(fileURL)")
}
}.resume()
}
And here's the code the code that's calling this function:
private func configureNavigationBar() {
navigationItem.rightBarButtonItems = [
UIBarButtonItem(title: Constants.Strings.download, style: .done, target: self, action: #selector(downloadVideo)),
UIBarButtonItem(image: UIImage(systemName: "icloud.and.arrow.down"), style: .done, target: self,
action: #selector(downloadVideo))
]
}