I am trying to upload file with params, but it fails. Is there something wrong with the code below?
refer Uploading file with parameters using Alamofire
Swift
Alamofire.upload(.POST, url, multipartFormData: { (multipartFormData) -> Void in
let fd = UIImageJPEGRepresentation(image,0.8)!
multipartFormData.appendBodyPart(data: fd, name: "image", fileName: "image.jpg", mimeType: "image/jpeg")
for (k, v) in params {
let d = v.dataUsingEncoding(NSUTF8StringEncoding)!
multipartFormData.appendBodyPart(data: d, name: k)
}
}) { (encodingResult) -> Void in
switch encodingResult {
case .Success(let upload, _, _):
upload.responseJSON { response in
if response.result.isSuccess {
print("success")
} else {
print("fail")
}
}
case .Failure(let encodingError):
self.view.makeToastCenter(message: "fail \(encodingError)")
}