How can upload a zip file into FTP server using sw

2019-06-12 15:16发布

问题:

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.

回答1:

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")
        }
 }