0

code:

let url = NSURL(string: urlString)
            let urlData1 = NSData(contentsOf: url! as URL)
            if(urlData1 != nil)
            {
                let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0];
                let fileManager = FileManager.default
                if let tDocumentDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first {
                    let filePathURL =  tDocumentDirectory.appendingPathComponent("eMedicoz")
                    if !fileManager.fileExists(atPath: filePathURL.path) {
                        do {
                            try fileManager.createDirectory(atPath: filePathURL.path, withIntermediateDirectories: true, attributes: nil)
                        } catch {
                            NSLog("Couldn't create document directory")
                        }
                    }
                NSLog("Document directory is \(filePathURL)")

                let filePath="\(filePathURL.path)" + "/" + fileName

             DispatchQueue.main.async {
                urlData?.write(toFile: filePath, atomically: true);
                    PHPhotoLibrary.shared().performChanges({
                        PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: NSURL(fileURLWithPath: filePath) as URL)
                    }) { completed, error in
                        if completed {
                            print("Video is saved!")
                            completionHandler(true,"Video Save",nil)
                        }
                        else{
                            completionHandler(false,"error",error! as NSError)
                        }
                    }
        }

How to encrypt/hide download file in document directory so that file not visible to the user in device in swift 3* Thanks in advance.

Dilip
  • 2,622
  • 1
  • 20
  • 27
Pintu Rajput
  • 621
  • 2
  • 8
  • 23

0 Answers0