If this is complete code, you have not actually started the download. NSURLSession tasks do not start automatically (unlike some NSURLConnection calls). You must explicitly call their resume method to start the download, or the tasks will just sit there and do nothing.
Secondly, you really should use a URLForResource, not a path, and then convert it to a URL. This should not break your code, but it is much easier to use the URLs to get started.
Third, if you really need to use the path, convenient methods (fileURLWithPath :) are your friend.
Fourth, you do not need to set Content-Length and IIRC, you probably should not, because you do not know what the length of the content will be if the NSURLSession negotiates any encoding (for example, file data compression).
Fifth, if the file is large, 30 seconds may not be long enough.
Sixth, if you are running newer versions of iOS or OS X, make sure that you either use a properly configured HTTPS server or add a suitable exception for application security.
Finally, if you want to include other POST options, rather than just providing information about the data block as the request body, you will have to use a streaming request. Of course, you can use the GET parameters trivially, and this is what I would recommend you do, because it is a much simpler way to do something. :-)
dgatwood
source share