A.Dominguez A.Dominguez - 1 month ago 151
Swift Question

How can upload a zip file into FTP server using swift 3 and iOS 10?

How can upload a zip file into FTP server using swift 3 and iOS 10? I need to do this in my app to send logs files.

Answer

You can use this framework to upload files to an FTP server: https://github.com/Constantine-Fry/rebekka

With this, you just need to set configuration in AppDelegate (like this) and to upload you use this code:

if let URL = NSBundle.main.URL(forResource:"MyLog", withExtension: "zip") {
        let path = "/upload/\(UUID.init().uuidString).zip"
        self.session.upload(URL, path: path) {
            (result, error) -> Void in
            print("Upload file with result:\n\(result), error: \(error)\n\n")
        }
 }
Comments