Alamofire.upload(multipartFormData:to:encodingCompletion:) accepts a URLConvertible for the argument to: Instead, you should use Alamofire.upload(multipartFormData:with:encodingCompletion:) , which takes a URLRequestConvertible for its with: argument.
I think your URL argument name, which is the same as the type of URL() , helps create weird compiler errors.
The following compilation for me:
let url = try! URLRequest(url: URL(string:"www.google.com")!, method: .post, headers: nil) Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(Data(), withName: "image", fileName: "file.png", mimeType: "image/png") }, with: url, encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in if((response.result.value) != nil) { } else { } } case .failure( _): break } } )
Jon brooks
source share