upload a file to a ftp server

Hello,

first of all i know ftp is outdated, but the customer wants, so it has to be.

How can i upload a file to an ftp server in swift?

I have hostname, username, password, port(as string) and the filepath to file on the phone(created in the same app)

If possible i want to avoid downloading any libraries.

Tanks in advance

IMO you should not implement FTP even though the customer wants it. FTP’s lack of security means that it’s not safe to use on the modern Internet. Is your customer happy with arbitrary folks being able to read their their plaintext user name and password off the ‘wire’? Because that’s an unavoidable aspect of FTP )-:

Regardless, you can run an FTP upload using the

CFFTPStream
API, as shown by the SimpleFTPSample sample code. Three things to note:
  • CFFTPStream
    has been formally deprecated, but it does continue to work about as well as it ever did.
  • There is no official replacement for

    CFFTPStream
    . Apple’s position is that you should not be using FTP.
  • The sample is in Objective-C, not Swift. It’s unlikely to be updated because of the previous two points.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
upload a file to a ftp server
 
 
Q