1

Following the Alamofire Documentation for multipart form data uploads the request should be something like this:

AF.upload(multipartFormData: { multiPart in
    multiPart.append(data!, withName: "file", fileName: logFileName, mimeType: "multipart/form-data")
}, to: url).responseDecodable(of: DecodableType.self) { response in
    debugPrint(response)
}

However when I try this myself, I get the error Generic parameter 'T' could not be inferred on the first line AF.upload(multipartFormData: { multiPart in.

I have not yet found a solution for what the correct way to do this is. Any suggestions are appeciated.

koen
  • 5,383
  • 7
  • 50
  • 89
ez4nick
  • 9,756
  • 12
  • 37
  • 69

1 Answers1

0

You can try uploading the request this way as well... :)

AF.upload(multipartFormData: { multiPart in
    multiPart.append(data!, withName: "file", fileName: logFileName, mimeType: "multipart/form-data")
}, to: url).response { response in
    debugPrint(response)
    guard let data = response.data, let model = try? JSONDecoder().decode(YourCustomResponse.self, from: data) else {
        return
    }
}
koen
  • 5,383
  • 7
  • 50
  • 89
Anish
  • 595
  • 1
  • 4
  • 16