gpt4 book ai didi

ios - 如何获取 base64 字符串的 icloud PDF 文件路径? swift 3

转载 作者:行者123 更新时间:2023-11-30 12:05:14 24 4
gpt4 key购买 nike

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

最佳答案

这是文件转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))
}

关于ios - 如何获取 base64 字符串的 icloud PDF 文件路径? swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46748985/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com