I upload a file with Alamofire in Home VC. But upload func in the class function. So I didnt get the progress operations. I guess I have to write delegate Method.
Anybody will help me?
My Question is in ViewController !!!
In SendPhoto.class
class SendPhoto {
func send() {
Alamofire.upload(
multipartFormData: { multipartFormData in
...
},
to: "",
headers:headers,
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.uploadProgress {progress in
print(progress.fractionCompleted)
}
upload.responseJSON { response in
}
case .failure(let encodingError):
print("File Upload Error")
print(encodingError)
}
})
}}
In ViewController
class HomepageVC: UIViewController .. {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func sendAction(_ sender: Any) {
SendPhoto().send()
// I want to keep this function progress and print to a label or etc. !!!
}
}