Reputation: 166
I am using UIDocumentBrowserViewController to browse the file and getting the URL of the selected file from UIDocumentBrowserViewControllerDelegate method.
func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentsAt documentURLs: [URL]) {
guard let fileUrl = documentURLs.first else { return }
do {
let fileData = try Data(contentsOf: fileUrl)
} catch {
print(error.localizedDescription)
}
}
Now I have to upload this file to our app server, so I am trying to convert it into Data but it's not converting. Getting an error 'The file "File name" couldn’t be opened because there is no such file'.
Upvotes: 0
Views: 93
Reputation: 166
I am using UIDocumentBrowserViewController but it's not working while I am trying to import the document always getting the issue so I use UIDocumentPickerViewController and its working fine for me.
Upvotes: 1