3

I want to upload files to an FTP. I would like to use NSURLSession for its backgrounding support. Apple documentation says it is supported but so far I have been unable to find it. The POC I have done is as follows:

The sample code from apple here uses NSStreams which I would like to avoid. On the other hand Apple's URL programming guide here says:

The URL loading system provides support for accessing resources using the following protocols:

  • File Transfer Protocol (ftp://)
  • Hypertext Transfer Protocol (http://)
  • Hypertext Transfer Protocol with encryption (https://)
  • Local file URLs (file:///)
  • Data URLs (data://)

So far I have searched through NSURLSessionUploadTask and NSURLSessionDataTask but I have only been able to find HTTP protocols, which will not work for FTP.

Much appreciate any help and thanks in advance.

Community
  • 1
  • 1
Rick
  • 1,177
  • 1
  • 19
  • 27

1 Answers1

1

From the NSURLSession Class Reference

The NSURLSession class and related classes provide an API for downloading content via HTTP.

You can use other library with CFNetwork Framework like WhiteRaccon to upload file to FTP server.

Himanshu Joshi
  • 3,391
  • 1
  • 19
  • 32
  • https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/CookiesandCustomProtocols/CookiesandCustomProtocols.html#//apple_ref/doc/uid/10000165i-CH10-SW3 again it says that `URL loading system natively supports the http, https, file, ftp, and data protocols. Implement a custom protocol by subclassing NSURLProtocol then registering the with the URL loading system using the NSURLProtocol class method registerClass:.When an NSURLSession,NSURLConnection,or NSURLDownload object initiates a connection for an NSURLRequest object` also http://nshipster.com/nsurlprotocol/ – Rick Apr 28 '14 at 12:29
  • Also dont want to use CFNetwork if NSURLSession can handle it because of the backgrounding support for NSURLSession in iOS 7 – Rick Apr 28 '14 at 12:57