How to get NSData from file by using PHAsset

前端 未结 2 555
半阙折子戏
半阙折子戏 2021-01-13 23:06

I have file at path

file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov

But when I try this code-

NSError *error;
NSData *d         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 23:32

    You can't access the NSURL directly as the files are outside of the sandbox of your app. Some frameworks (like AVPlayer) have exception entitlements and can access the URLs. To access the data of PHAsset objects take a look at the following methods of PHImageManager:

    For images: requestImageDataForAsset

    For videos: requestExportSessionForVideo

提交回复
热议问题