Я использую documentPicker для получения URL-адреса любого документа, а затем загружаю его в базу данных. Я выбираю файл (pdf, txt ..), загрузка работает, но я хочу ограничить размер файла.
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
self.file = url //url
self.path = String(describing: self.file!) // url to string
self.upload = true //set upload to true
self.attachBtn.setImage(UIImage(named: "attachFilled"), for: .normal)//set image
self.attachBtn.tintColor = UIColor.black //set color tint
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)")
}
}
Я получаю сообщение об ошибке, этот файл не существует, где средство выбора документов сохраняет файл и как получить его атрибуты.