INNER CODE UNIT · Swift
openFile
cometchat/cometchat-uikit-flutter · packages/cometchat_uikit/ios/Classes/SwiftCometchatChatUikitPlugin.swift:449
private func openFile(args: [String: Any]) {
guard let path = args["file_path"] as? String else { return }
previewItem = NSURL(fileURLWithPath: path)
let preview = QLPreviewController()
preview.dataSource = self
CometchatChatUikitPlugin.uiViewController?.present(preview, animated: true)
}
// MARK: - Save As (document export)
/// "Save as" — presents the system location picker (export mode) so the user
/// chooses where the file lands. Uses the cached local copy when present,
/// else downloads the URL to a temp file first. Result to Flutter: a
/// non-empty string on success, or nil on cancel/failure.
private func saveFileWithPicker(args: [String: Any], result: @escaping FlutterResult) {
let urlStr = args["url"] as? String
let fileName = (args["fileName"] as? String) ?? "download"
let localPath = args["path"] as? String