Swift 3 / Alamofire 4.0 (Addendum to the accepted answer)
To append to multipartFormData
in Swift 3 / Alamofire 4.0, use the following method of MultipartFormData
:
public func append(_ data: Data, withName name: String) { /* ... */ }
And, to convert String
to Data
, the data(using:)
method of String
. E.g.,
multipartFormData.append("comment".data(using: .utf8)!, withName: "comment")