nsurlsessiondownloadtask

How can I check that an NSData blob is valid as resumeData for an NSURLSessionDownloadTask?

99封情书 提交于 2019-11-28 19:21:28
问题 I have an app that's using background downloads with the new NSURLSession APIs. When a download cancels or fails in such a way that NSURLSessionDownloadTaskResumeData is provided, I store the data blob so that it can be resumed later. A very small amount of the time I am noticing a crash in the wild: Fatal Exception: NSInvalidArgumentException Invalid resume data for background download. Background downloads must use http or https and must download to an accessible file. The error occurs here

Showing the file download progress with NSURLSessionDataTask

只愿长相守 提交于 2019-11-27 12:24:16
I want to display file download progress (how many bytes are received) of particular file. It works fine with the NSURLSessionDownloadTask .My question is I want to achieve the same with the NSURLSessionDataTask. Here is the code which receives file into NSData and writes to document folder: NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]]; NSURLSessionDataTask * dataTask = [defaultSession

Swift - Downloading video with downloadTaskWithURL

荒凉一梦 提交于 2019-11-27 07:54:42
I'm downloading a video thanks to downloadTaskWithURL and I'm saving it to my gallery with this code : func saveVideoBis(fileStringURL:String){ print("saveVideoBis"); let url = NSURL(string: fileStringURL); (NSURLSession.sharedSession().downloadTaskWithURL(url!) { (location:NSURL?, r:NSURLResponse?, e:NSError?) -> Void in let mgr = NSFileManager.defaultManager() let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]; print(documentsPath); let destination = NSURL(string: NSString(format: "%@/%@", documentsPath, url!.lastPathComponent!) as String);

Resume NSUrlSession on iOS10

我与影子孤独终老i 提交于 2019-11-27 06:03:13
iOS 10 is going to be released soon so it worth to test applications for compatibility with it. During such test we've discovered that our app can't resume background downloads on iOS10. Code that worked well on previous versions does not work on new one, both on an emulator and on a device. Instead of reducing our code to minimal working test case I've searched internet for NSUrlSession tutorials and tested them. Behaviour is the same: resuming works on previos versions of iOS but breaks on 10th. Steps to Reproduce: Download a project form NSUrlSession tutorial https://www.raywenderlich.com

Showing the file download progress with NSURLSessionDataTask

ぐ巨炮叔叔 提交于 2019-11-26 18:11:38
问题 I want to display file download progress (how many bytes are received) of particular file. It works fine with the NSURLSessionDownloadTask .My question is I want to achieve the same with the NSURLSessionDataTask. Here is the code which receives file into NSData and writes to document folder: NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject

Swift - Downloading video with downloadTaskWithURL

左心房为你撑大大i 提交于 2019-11-26 13:54:02
问题 I'm downloading a video thanks to downloadTaskWithURL and I'm saving it to my gallery with this code : func saveVideoBis(fileStringURL:String){ print("saveVideoBis"); let url = NSURL(string: fileStringURL); (NSURLSession.sharedSession().downloadTaskWithURL(url!) { (location:NSURL?, r:NSURLResponse?, e:NSError?) -> Void in let mgr = NSFileManager.defaultManager() let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]; print(documentsPath); let

Resume NSUrlSession on iOS10

半城伤御伤魂 提交于 2019-11-26 11:49:50
问题 iOS 10 is going to be released soon so it worth to test applications for compatibility with it. During such test we\'ve discovered that our app can\'t resume background downloads on iOS10. Code that worked well on previous versions does not work on new one, both on an emulator and on a device. Instead of reducing our code to minimal working test case I\'ve searched internet for NSUrlSession tutorials and tested them. Behaviour is the same: resuming works on previos versions of iOS but breaks