我试了所有的方法,但每次我试图上传这个视频时,我都遇到了这个错误。错误
domain=nscocoaerrordomain code=257“无法打开文件img_1773.mov,因为您没有查看该文件得权限。”
[![fileprivate func getVideoFromasset() {
let imgManager = PHImageManager.default()
let fetchVideos = PHVideoRequestOptions()
fetchVideos.isNetworkAccessAllowed = true
fetchVideos.deliveryMode = .automatic
guard let asset = self.videoAsset else {
return
}
imgManager.requestPlayerItem(forVideo: asset, options: fetchVideos, resultHandler: { (data, info) in
guard let video = data?.asset as? AVURLAsset else { return }
print(video.url)
self.urlAsset = video.url
self.getVideoFromUrl(url: video.url)
})
}
@objc fileprivate func UploadVideo() {
guard let url = self.urlAsset else {return}
print(url.absoluteString)
if self.videoUrl == nil {
do {
let filedat = try Data(contentsOf: url)
let pffile = PFFile(name: "sdsd", data: filedat)
pffile?.saveInBackground({ (data, error) in
print(error)
}, progressBlock: { (intt) in
print(intt)
})
} catch {
print(error)
}
} else {
print(self.videoUrl)
print("upload from url file")
}
}][1]][1]
Error domain=nscocoaerrordomain code=257“无法打开文件img_1773.mov,因为您没有查看该文件得权限。”UserInfo=nsFilePath=/var/mobile/media/dcim/101Apple/img_1773.mov,NsUnderlyingError=0x174254280 Error Domain=nsPosixErrorDomain Code=1“不允许操作}
文件:///var/mobile/media/dcim/101apple/img_1773.mov
我需要帮助!!
我上传视频也面临同样的问题。对于云视频是上传,然而,对于视频,这是在手机内存面临的错误。所有你需要做的,而不是Url路径使用NSData视频,不是来自云。希望这对你有帮助。谢谢。
[[PHImageManager defaultManager] requestAVAssetForVideo:selectedImage
options:options
resultHandler:
^(AVAsset * _Nullable avasset,
AVAudioMix * _Nullable audioMix,
NSDictionary * _Nullable info)
{
AVURLAsset *avurlasset = (AVURLAsset*) avasset;
NSData *data = [NSData dataWithContentsOfURL:avurlasset.URL];
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:avurlasset.URL options:nil];
AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
generate1.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 2);
CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *thumbNailImage = [[UIImage alloc] initWithCGImage:oneRef];
NSString *typeOfImage = @"storingVideoPath";
NSMutableDictionary *dictForImagePath = [[NSMutableDictionary alloc] init];
[dictForImagePath setValue:flStrForObj(selectedImage.localIdentifier) forKey:@"uniqueIdenifierForAsset"];
[dictForImagePath setObject:indexPath forKey:@"indexPath"];
[dictForImagePath setValue:typeOfImage forKey:@"imageType"];
[dictForImagePath setValue:data forKey:@"imageValue"];
[dictForImagePath setObject:thumbNailImage forKey:@"thumnailImage"];
if(![arrayOfLibImages containsObject:dictForImagePath]) {
[arrayOfLibImages addObject:dictForImagePath];
dispatch_async(dispatch_get_main_queue(), ^{
[self.collectionViewForPickedPhotos reloadData];
});
}
}];
}
在视频/图像上传之前,需要检查的点很少。
1您必须具有在info.plist中定义的权限。