0

i have task that download image through UIDocumentInteractionController, however when i clicked on the Save Image button, it displayed the error log as below:

Video /Users/khanhnd/Library/Developer/CoreSimulator/Devices/13D3E1DA-DB0A-40C2-81EC-9937C7143A2E/data/Containers/Data/Application/83FD51AB-882A-462C-8804-21602AECB030/Documents/storage/IMG_2793.JPG cannot be saved to the saved photos album: Error Domain=AVFoundationErrorDomain Code=-11828

Here is my code:

                if statusCode == 200 {
                let viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewFileStorageController") as! ViewFileStorageController
                let data = NSData(contentsOfURL: filePath!)
                do {
                    let object = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
                    if let dictionary = object as? [String: AnyObject] {
                        print(dictionary["status"])
                        let status = dictionary["status"] as! Int
                        let errorMsg = dictionary["description"] as? String
                        if status == 400 {
                            let alertController = SLZAlertController(title:errorMsg, message: nil, preferredStyle: .Alert)
                            alertController.addAction(SLZAlertAction(title: "OK", style: .Default, handler: nil))
                            alertController.show(inViewController: self, animated: true)
                        }
                    }
                } catch {
                    // Handle Error
                }

                viewController.pathFileUrl = filePath
                print("file path is \(filePath)")
                viewController.titleNav = self.nameFile!
                self.documentController = UIDocumentInteractionController.init(URL: filePath!)
                self.documentController!.presentOptionsMenuFromRect(self.cellFrame!, inView: self.view, animated: true)

I think in this case ios thought my image is a video.But still stucking in it. Please any one can help me solve this. Thank you so much.

  • The code you posted has nothing to do with your issue. Post the relevant code. – rmaddy Jan 10 '17 at 04:00
  • 2 last row is the declaration of UIDocumentInteractionController to display download option. And the above parts is fetching file path from API. Did you get it? – Duy Khanh Nguyen Jan 10 '17 at 04:05

0 Answers0