Created
November 16, 2016 00:36
-
-
Save yoshimax/58e7c6afa003be27d1423152d3beb05b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Alamofire4 / Swift3 multipart data + prams upload | |
Alamofire.upload(multipartFormData:{ multipartFormData in | |
multipartFormData.append(self.imageNSURL, withName: "room[image]") | |
let roomText:String = self.roomName.text! as String | |
let bodyText = self.roomIntroduction.text | |
if let data = roomText.data(using: String.Encoding.utf8) { | |
multipartFormData.append(data, withName: "room[title]") | |
} | |
if let data = bodyText?.data(using: String.Encoding.utf8) { | |
multipartFormData.append(data, withName: "room[body]") | |
} | |
} | |
usingThreshold:UInt64.init(), | |
to:url, | |
method:.post, | |
headers:["Authorization": keychain["token"]!], | |
encodingCompletion: { encodingResult in | |
switch encodingResult { | |
case .success(let upload, _, _): | |
upload.responseJSON { response in | |
debugPrint(response) | |
} | |
case .failure(let encodingError): | |
print(encodingError) | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment