Created
February 25, 2017 14:37
-
-
Save korgx9/c83ebacf9fd0e9bc15d595ec0f624499 to your computer and use it in GitHub Desktop.
This file contains 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
func postImages(_ orderId: String, images: [UIImage]) { | |
var tmpImages = images | |
Alamofire.upload(multipartFormData: { | |
multipartFormData in | |
multipartFormData.append(orderId.data(using: String.Encoding.utf8, allowLossyConversion: false)!, withName: "order") | |
multipartFormData.append(UIImageJPEGRepresentation(images[0], 95)!, withName: "image", fileName: orderId + "_picture.jpg", mimeType: "image/jpg") | |
}, to: UserOrderUploadImageURL, encodingCompletion: { | |
encodingResult in | |
switch encodingResult { | |
case .success(let upload, _, _): | |
upload.responseJSON { | |
response in | |
debugPrint(response) | |
tmpImages.removeFirst() | |
if tmpImages.count > 0 { | |
self.postAdvertImages(orderId, images: tmpImages) | |
} | |
} | |
case .failure(let encodingError): | |
print(encodingError) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment