I will try to send the photo along with the parameters, but to catch that I want to send a JSON array to the server. Alamofire doesn't seem to have a way to post a list Data, so another good alternative to this?
key part of the problem:
var encodedTags: [Data] = tags.map({ return $0.data(using: .utf8)!})
mpd.append(encodedTags, withName: key)
as part of this download call:
let parameters: [String: Any] = ["username": "TheCooliest", ..., "tags": ["KoolKid", "TheKooliest", "BetterThanKimK"]
...
upload(multipartFormData: { (mpd) in
mpd.append(url, withName: "file", fileName: "weeknd.jpg")
for (key, value) in parameters {
if let tags = value as? [String], key == "tags" {
var encodedTags = tags.map({ return $0.data(using: .utf8)!})
mpd.append(encodedTags, withName: key)
}
}
}
source
share