Created
May 11, 2015 06:42
-
-
Save slav123/5bc82bb48749ac13926a to your computer and use it in GitHub Desktop.
upload image from UIPicker
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
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) { | |
// do something with selectedImage and originalImage | |
let timage = UIImageJPEGRepresentation(image, 1.0); | |
if image != nil { | |
//UIImageJPEGRepresentation(selectedImage, <#compressionQuality: CGFloat#>) | |
upload(.POST, "http://api.localhost/image", timage) | |
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in | |
var fp : Float | |
if totalBytesWritten > 0 { | |
fp = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite); | |
dispatch_async(dispatch_get_main_queue()) { | |
self.progressView.setProgress(fp, animated: true) | |
} | |
} | |
} | |
.responseString { (request, response, jeson, error) in | |
println(jeson) | |
println(response) | |
} | |
} | |
picker.dismissViewControllerAnimated(true, completion:nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment