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 siz
First of all, in the file system you get the path of a URL with the path
property.
self.path = url.path
But you don't need that at all. You can retrieve the file size from the URL directly:
self.path = String(describing: self.file!) // url to string
do {
let resources = try url.resourceValues(forKeys:[.fileSizeKey])
let fileSize = resources.fileSize!
print ("\(fileSize)")
} catch {
print("Error: \(error)")
}