When app save photos, it will be shown in Photos app. But I want to save photos inside app folder and other apps don't able to access it.
I get the path to save files as below:
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
How can I do it?
Someone told me about using secure storage. Can it be my solution?
Save an image to the App document folder like this:
func saveImageDocumentDirectory(image: UIImage, name:String){
let paths = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(name)
let imageData = UIImageJPEGRepresentation(image, 0.5)
FileManager.default.createFile(atPath: paths as String, contents: imageData, attributes: nil)
}
There is no reason to use a secure store (unless you also want to protect data from hacking etc), as the App document folder is only accessable to your App.
Also, take a look at this blog: https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html
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