title: Swift - Get file size from url
body: <p>i am using documentPicker to get url path of any document and then uploaded to the database. I am choosing file (pdf, txt ..) , the upload is working but i want to limit the size of the file .</p>
  
  <pre><code> 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)")
          }
  
      }
  </code></pre>
  
  <p>I get the error message , this file does not exist , where does the document picker save the file and how to get his attributes.</p>