如何获取pdf文件路径?并将pdf文件隐藏到base64字符串
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
if controller.documentPickerMode == UIDocumentPickerMode.import {
// This is what it should be
// self.txtName.text = String(contentsOfFile: url.path)
//hear get base64 string
}
}
答案 0 :(得分:0)
这是文件到base64的代码:
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
let fileData = try! Data.init(contentsOf: url)
let base64String: String = fileData.base64EncodedString(options: NSData.Base64EncodingOptions.init(rawValue: 0))
}