Ryan Bigg Ryan Bigg - 1 year ago 138
Swift Question

Expression type '()' is ambiguous without more context

I'm trying to do an upload with Alamofire using this code (where photo.image is a UIImage)

let imageData = UIImageJPEGRepresentation(photo.image, 1.0)

multipartFormData: { multipartFormData in
multipartFormData.append(data: imageData!, withName: "unicorn")
to: "https://httpbin.org/post",
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
case .failure(let encodingError):

However, this tells me "Expression type '()' is ambiguous without more context.

I am not sure what I'm doing wrong here and would love some advice.

Answer Source

I had the wrong arguments for multipartFormData. Here's what worked:

multipartFormData: { multipartFormData in
                    multipartFormData.append(imageData!, withName: "photo", fileName: "image.jpg", mimeType: "image/jpg")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download