This seems to be something that should be very straight forward based on all the examples and docs I've read, but I am still unable to get this to work for some strange reason.
I am using Alamofire Frame work to download a video from instagram. Once downloaded, I then want to save the video to the Camera Roll. Here is my code to Download the video and save to disk:
let destination: (NSURL, NSHTTPURLResponse) -> (NSURL) = {
(temporaryURL, response) in
if let directoryURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
let finalPath = directoryURL.URLByAppendingPathComponent("\(Scripts.dateToString2(date: NSDate())).\(response.suggestedFilename!)")
InstagramEngine.downloadMediaPath = finalPath
Scripts.log("Final Path >> \(finalPath)")
return finalPath
}
return temporaryURL
}
let request = Alamofire.download(.GET, self.videoURL, destination)
request.response { _, response, data, error in
NSNotificationCenter.defaultCenter().postNotificationName(kMediaDownloadComplete, object: nil)
}
Once the download is complete, the Notification is triggered which calls this function to save it to Camera Roll:
UISaveVideoAtPathToSavedPhotosAlbum(InstagramEngine.downloadMediaPath.URLString, self, Selector("video:didFinishSavingWithError:contextInfo:"), nil)
Everything is being called based on my log statements and no errors occured. Even didFinishSavingWithError is being called successfully for the UISaveVideoAtPathToSavedPhotosAlbum and I confirmed no errors found. But when I go check the camera roll, I still see no video saved there. Any ideas?