Here the alamofire code i am using
params is a dictionary [String:Any]
Alamofire.upload(
multipartFormData: { MultipartFormData in
for (key, value) in params {
if let image = value as? UIImage {
if let imageData = UIImageJPEGRepresentation(image, 0.2) {
MultipartFormData.append(imageData, withName: "image", fileName: "file.jpg", mimeType: "image/jpg")
}
}else {
MultipartFormData.append(String(describing: value).data(using: String.Encoding.utf8)!, withName: key)
}
}
}, to:url, method: .patch, headers: ["token": authToken,"Content-Type":"application/json"]) { (result) in
switch result {
case .success(let upload, _, _):
upload.responseJSON { response in
guard response.result.isSuccess else {
print(response.error?.localizedDescription ?? "Error while requesting")
return
}
if let value = response.result.value {
let json = JSON(value)
}
}
case .failure(let encodingError):
print(encodingError)
}
}
I want to upload an image to the server, read some post for uploading via alamofire but none seems to be working for me? Please help me find the issue here.
Solutions given in the duplicate question arent working for me
Thank you