ARTICLE AD BOX
.externalStorage definitely doesn't give you direct file access as the system manages the storage location, Apple manages the storage location internally and doesn't appear to expose it. Seems like this was done by-design. For your specific use-case, manual file management with SwiftData references might be the right pattern.
What you can do instead is store the file (or metadata) manually and keep the reference in SwiftData, you should be able to get the url of the file by doing it this way.
You could do something like this:
@Model final public class LocalFileModel { @Attribute(.unique) var href: String var localFileName: String? var fileURL: URL? { guard let fileName = localFileName else { return nil } return FileManager.default .urls(for: .cachesDirectory, in: .userDomainMask)[0] .appendingPathComponent("CachedFiles/\(fileName)") } }This should give you querying/relationship management using SwiftData, real file URLs for sharing, etc.. as well as control over storage location.
Since files aren't auto-deleted with the model, you'll also have to handle deletion. I think this approach should give you the ability to use SwiftData for metadata and querying and real filesystem access for the actual data.
