I am trying to upload a file,
if fileManager.fileExists(atPath: nsFileUrl.path) {
nsUrlSessionUploadTask = nsSession.uploadTask(with: request as URLRequest, fromFile: nsFileUrl)
}
I have added a check if file exists and then launch upload task but the app randomly crashes with
NSInvalidArgumentException Reason:Cannot read file at path
I have two questions
1. What could the reason be? Can it happen if the file got deleted from a different thread, after if check passes
2. Is there a way to handle this exception?