如何从 UIDocumentPickerController 获取文件 url,以便稍后上传到我的服务器?发送文件作为实现的电报。现在只能从 icloud 下载文件并稍后发送。但是我想学习如何在电报中实现?
这是我现在的代码:
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)
}
}