I use documentPicker to get the URL of any document and then uploaded to the database. I select a file (pdf, txt ..), the download works, but I want to limit the file size.
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
self.file = url
self.path = String(describing: self.file!)
self.upload = true
self.attachBtn.setImage(UIImage(named: "attachFilled"), for: .normal)
self.attachBtn.tintColor = UIColor.black
sendbtn.tintColor = UIColor.white
do
{
let fileDictionary = try FileManager.default.attributesOfItem(atPath: self.path!)
let fileSize = fileDictionary[FileAttributeKey.size]
print ("\(fileSize)")
}
catch{
print("Error: \(error)")
}
}
I get an error, this file does not exist, where the document collector saves the file and its attributes.
source
share