FileManager returns permission error while trying to get the file size, in iOS 13 devices.
do {
let attr = try FileManager.default.attributesOfItem(atPat
iOS 13 SDK consider photo app as an another app, so when we dismiss the image picker controller video url will be invalidate.
I had the problem before when I try to upload video to AWS, what i did just create a temporary folder and copy the existing video url path before dismiss the Image-picker.then it upload, it's worked.
func createDirectory(videoURL:URL){
let Directorypath = getDirectoryPath()
var objcBool:ObjCBool = true
let isExist = FileManager.default.fileExists(atPath:Directorypath,isDirectory: &objcBool)
// If the folder with the given path doesn't exist already, create it
if isExist == false{
do{
try FileManager.default.createDirectory(atPath: Directorypath, withIntermediateDirectories: true, attributes: nil)
}catch{
print("Something went wrong while creating a new folder")
}
}
let fileManager = FileManager()
do {
if fileManager.fileExists(atPath:Directorypath) {
try? fileManager.removeItem(at: URL(fileURLWithPath:Directorypath))
}
try fileManager.copyItem(at:videoURL.absoluteURL, to: URL(fileURLWithPath:Directorypath))
self.imagePicker.dismiss(animated: true, completion:nil)
}catch let error {
print(error.localizedDescription)
}
}