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