如何获得base64字符串的icloud PDF文件路径?斯威夫特3

时间:2017-10-14 20:22:08

标签: ios swift icloud

如何获取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
    }
}

1 个答案:

答案 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))
}