I'm trying to get video from a UIImagePicker and send it as data across my restkit API.
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let videoURL = info["UIImagePickerControllerReferenceURL"] as? NSURL
var movieData: NSData?
do {
movieData = try NSData(contentsOfURL: videoPath, options: .DataReadingMappedIfSafe)
} catch {
print(error)
movieData = nil
return
}
// Multipart Form Request for RestKit POST goes here
imagePickerController.dismissViewControllerAnimated(true, completion: nil)
}
Getting the following error:
Error Domain=NSCocoaErrorDomain Code=256 "The file “asset.MOV” couldn’t be opened." UserInfo={NSURL=assets-library://asset/asset.MOV?id=B906AB1B-F311-47BA-8FE9-EE7AADDB7796&ext=MOV}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let videoURL = info["UIImagePickerControllerMediaURL"] as? NSURL
do {
let video = try NSData(contentsOfURL: videoPath, options: .DataReadingMappedIfSafe)
} catch {
print(error)
return
}
imagePickerController.dismissViewControllerAnimated(true, completion: nil)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With