Skip to content

Commit

Permalink
Merge pull request #44 from maxkonovalov/multipart-params
Browse files Browse the repository at this point in the history
Fix multipart params parsing
  • Loading branch information
s4cha authored Jun 12, 2017
2 parents bdc4a49 + 7503488 commit fd4a15c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ws/WSRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,19 @@ open class WSRequest {
progress:@escaping (Float) -> Void) {
upload(multipartFormData: { formData in
for (key, value) in self.params {
if let int = value as? Int {
let str = "\(int)"
if let d = str.data(using: String.Encoding.utf8) {
formData.append(d, withName: key)
}
} else {
if let str = value as? String, let data = str.data(using: String.Encoding.utf8) {
formData.append(data, withName: key)
let str: String
switch value {
case let opt as Any?:
if let v = opt {
str = "\(v)"
} else {
continue
}
default:
str = "\(value)"
}
if let data = str.data(using: .utf8) {
formData.append(data, withName: key)
}
}
formData.append(self.multipartData,
Expand Down

0 comments on commit fd4a15c

Please sign in to comment.