I have a image cached in my apps document folder. I want to copy it in document folder. Till now i know that i can load my image as UIImage and then convert it to data and save it in my destination path. But is there any better approach than this? Like i don't want to convert my image in UIImage and again convert it to data and write.
My code for png is:
// Here sourcePath is original image path for example file//Document/dummy.png
// destinationPath is the path where i want to save my image for example file//Document/Image/anything.png
if let img = UIImage(contentsOfFile: sourcePath), let data = img.pngData() {
do {
try data.write(to: destinationPath)
} catch {
}
}