How to download icloud videos?

I want to save the PHAsset which is an iCloud video in applictions temporary directory. I tried using exportAsynchronouslyWithCompletionHandler buy setting export session output url as temporary directory url. I donnot know is it a right way to do, but I got following error,


Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1900f330 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x190c1830 "The operation couldn’t be completed. (OSStatus error -12780.)", NSLocalizedFailureReason=An unknown error occurred (-12780)}


Please suggest what could be the solution.


Thank you!

Replies

I'm getting the same error, but it occurs way more often for larger videos.

Just adding my vote here; getting the same issue.

Had the same issue, what worked for me was requesting an AVAssetExportSession from PHCachingImageManager and using that to export my icloud video. Like this:
Sorry for the old obj c code, it's a very old project.

Code Block
[self.imageManager requestExportSessionForVideo:asset options:videoOption exportPreset:AVAssetExportPresetPassthrough resultHandler:^(AVAssetExportSession * _Nullable exportSession, NSDictionary * _Nullable info) {
// You might use the exporter here, or pass it along
}];