1

Before iOS 9, I use the CFStream APIs (which are deprecated after iOS 9) to list / download / upload files via FTP.

Now, I have to transfer my program to adapt iOS 9.

How can I download files from FTP via NSURLSessionStreamTask?

Pang
  • 9,564
  • 146
  • 81
  • 122
ru1eX
  • 11
  • 1
  • check this [link](https://medium.com/swift-programming/learn-nsurlsession-using-swift-part-3-upload-3a5be9a69950) – PK20 Oct 20 '15 at 02:40

1 Answers1

0

NSURLSession supports downloading from FTP servers. It does not support uploading, to the best of my knowledge, and it probably does not support retrieving file listings, either. In fact, even its predecessor, NSURLConnection, did not support those things. Support was never added, because FTP has basically been considered deprecated since the mid-1990s.

If your app is primarily an FTP app, keep using the existing API and squelch the deprecation warnings using pragmas.

If your app is any other kind of app, move away from FTP. It is a terrible way to upload content, and should be used only for backwards compatibility with legacy systems that cannot be upgraded to use a more secure protocol like SFTP, WebDAV over HTTPS, POST over HTTPS, WebDAV with digest auth, POST with digest auth, etc.

dgatwood
  • 10,129
  • 1
  • 28
  • 49
  • Thanks. In fact, it's possible to use the NSURLSession to list / upload / download files via ftp, but some differences. For example, you must write your own parsing method(which provided by the old APIs) to parse file lists from the response data. Now, my only problem is how to resume broken downloads using new APIs. – ru1eX Dec 15 '15 at 01:45