5

I'm attempting to upload of a file using NSURLSession's support for background uploads.

NSURLSessionTask *task = [session uploadTaskWithRequest:request fromFile:fileUrl];

Everything works great in iOS8 but when I run the same code in iOS7, the task gets immediately cancelled with the error message:

"Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo=0x17df82a0 {NSErrorFailingURLKey=https://my.url.com/, NSErrorFailingURLStringKey=https://my.url.com/, NSLocalizedDescription=cancelled}"

As far as I can tell, this should be supported in iOS7 but I haven't found anything to explain why this would be happening or how to fix it.

ideaencoder
  • 173
  • 1
  • 8
  • 1
    found a solution by now? got the same issue, without uploading, just a get request, in swift 2.0, ios 8 and ios 9. – CularBytes Jul 08 '15 at 19:21
  • @RageCompex i'm getting the exact same thing in Swift 2 and iOS 8...did you manage to come up with a solution? – cph2117 Jul 22 '15 at 22:40
  • 1
    @cph2117 I am trying to remember when and where I got it and how I fixed it. My search history shows this github page: https://github.com/Alamofire/Alamofire/issues/157 I think I had done the same, keep the manager as a global variable. – CularBytes Jul 23 '15 at 16:06
  • @RageCompex thanks for helping. I actually already have a custom class that has the network manager as a retained instance, so it must be something else! – cph2117 Jul 23 '15 at 17:55
  • but is your custom class retained :)? Then I have no solution for you, sorry and happy debugging! We all love it so much... – CularBytes Jul 23 '15 at 18:27
  • Faced similar issue and I have realised that `from*:` in `NSURLSession#uploadTaskWithRequest:from*:` cannot be `nil` - thanks to Andy Ibanez who described it here - https://stackoverflow.com/a/38512824/2004186 – Krzysztof Skrzynecki Dec 19 '19 at 16:35

0 Answers0