I would like to save images from my app to the Files app
in the following hierarchy:
Files
MyAppFolder
FolderA
fileA1.png
fileA2.png
fileA3.png
FolderB
fileB1.png
fileB2.png
fileB3.png
I am trying to use the following code from here:
func saveImage(image: UIImage) -> Bool {
guard let data = UIImagePNGRepresentation(image) else {
return false
}
guard let directory = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) as NSURL else {
return false
}
do {
try data.write(to: directory.appendingPathComponent("fileName.png")!)
return true
} catch {
print(error.localizedDescription)
return false
}
}
But the file is no where to be found in the Files app.
I guess the url to the Files should be something else. But what?