Hey, I'm not sure I'm even in the correct ballpark - trying to allow my app to download largish videos from user's OneDrive and G-Drive to app
- Is it correct to use NSFileCoordinator in this way?
- How do I report progress as it downloads the video (is it possible?)
- Is it correct to dismiss the picker like this?
- anything else wrong (or, like is....any of it correct? :)
it's sort of working with my contrived examples (I created new personal G-drive / Onedrive accounts, and copied vids up there), but...when I use a file from our corporate OneDrive, from shared folder, I get:
"NSCocoaErrorDomain Code=3328 "The requested operation couldn’t be completed because the feature is not supported."
Is this the NSFileProvider extension (Microsoft's) complaining?
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else { return }
let isSecurityScoped = url.startAccessingSecurityScopedResource() print("(#function) - iSecurityScoped = (isSecurityScoped)") print("(#function) - document at (url)") let filename = String(UUID().uuidString.suffix(6)) + "_" + url.lastPathComponent
let newURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent(filename) let readingIntent = NSFileAccessIntent.readingIntent(with: url, options: .withoutChanges)
fileCoordinator.coordinate(with: [readingIntent], queue: queue) { error in
defer { if isSecurityScoped { url.stopAccessingSecurityScopedResource() } }
if let error = error { print("(#function) - (error)") return }
let safeURL = readingIntent.url
do { let fileData = try Data(contentsOf: safeURL) try fileData.write(to: newURL, options: .atomic) print("(#function) - SUCCESS - newURL = (newURL)") } catch { print("(#function) - NOOOOO - (error)") } }
controller.dismiss(animated: true) }