Alamofire 4 Upload mit Parametern
Ich gehe wie folgt vor, um eine PNG-Datei mit Parametern hochzuladen:
Alamofire.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(UIImagePNGRepresentation(tempImage!)!, withName: "file", fileName: "picture.png", mimeType: "image/png")
// Send parameters
multipartFormData.append((UserDefaults.standard.value(forKey: Email) as! String).data(using: .utf8)!, withName: "email")
multipartFormData.append("png".data(using: .utf8)!, withName: "type")
},
to: "user/picture",
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
debugPrint("SUCCESS RESPONSE: \(response)")
}
case .failure(let encodingError):
self.removeSpinnerFromView()
print("ERROR RESPONSE: \(encodingError)")
}
}
)
Problem ist, dass ich auf meinem Server das @ nicht seemail
undtype
Formularfelder. Dazu habe ich online gepostete Beispiele verfolgt. Gibt es etwas, das ich anders machen sollte?
BEARBEITE
Wenn ich den Teil entferne, in den ich geschrieben habe:
multipartFormData.append(UIImagePNGRepresentation(tempImage!)!, withName: "file", fileName: "picture.png", mimeType: "image/png")
ANN sind die Parameter enthalten. Ansonsten nicht, ich denke das ist ein Fehler in Alamofire 4.0.1.