How get file url from UIDocumentPickerController, for later upload to my server? Sending files as implemented Telegram. Now there is only the possibility to download a file from icloud and send later. But I want to learn how to implement in the telegram?
This is my code now:
func openPicker() {
let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.data"], inMode: UIDocumentPickerMode.Open)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = UIModalPresentationStyle.FullScreen
self.presentViewController(documentPicker, animated: true, completion: nil)
}
func documentPicker(controller: UIDocumentPickerViewController, didPickDocumentAtURL url: NSURL) {
if controller.documentPickerMode == UIDocumentPickerMode.Open {
let fileManager = NSFileManager.defaultManager()
print(fileManager.fileExistsAtPath(url.path!))
let data = NSData(contentsOfFile: url.path!)
let document = UIDocument(fileURL: url)
}
}