我制作了一个 SwiftUI DocumentApp,它可以读取大型媒体文件但不需要编写它们。在我的文档中,我只想存储文件的 URL,以便可以使用例如 AVAudioFile 加载它。我无法解决如何在不创建文件的临时副本的情况下执行此操作,就像作者在此处所做的那样,因为无法从 fileWrapper 获取文件 URL
我试图使用 configuration.file.regularFileContents (Data) 创建一个管道,但到目前为止我没有成功从该管道读取。
init(configuration: ReadConfiguration) throws {
let tempURL = makeTemporaryFileURL()
FileManager.default.createFile(atPath: tempURL.path, contents: configuration.file.regularFileContents, attributes: nil)
audioFileUrl = tempURL
}