How can I read a dataless file from within the same or another FileProvider extension?

How can I read a dataless file from within the same or another FileProvider extension?

When I pass the visible URL to AVAsset from AVFoundation, it throws the following error:

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x15b01b1e0 {Error Domain=NSPOSIXErrorDomain Code=11 "Resource deadlock avoided"}, NSLocalizedFailureReason=An unknown error occurred (11), AVErrorFailedDependenciesKey=(
    "assetProperty_Tracks"
), NSURL=file:///Users/<<username>>/Library/CloudStorage/<<file-path>>, NSLocalizedDescription=The operation could not be completed}

The code snippet works fine if executed as a separate Swift process.

I'm using AVAsset with AVAssetExportSession to export a subset of the file being read. So I can't use NSFileProviderManager.requestDownloadForItem(withIdentifier:, requestedRange:) because I don't know the offset range required by the AVFoundation library.

Answered by Engineer in 802803022

Using NSFileCoordination on the URL to the file will cause it to be downloaded while the accessor block is running. See https://developer.apple.com/documentation/foundation/nsfilecoordinator/1407416-coordinatereadingitematurl?language=objc

Accepted Answer

Using NSFileCoordination on the URL to the file will cause it to be downloaded while the accessor block is running. See https://developer.apple.com/documentation/foundation/nsfilecoordinator/1407416-coordinatereadingitematurl?language=objc

How can I read a dataless file from within the same or another FileProvider extension?
 
 
Q