gpt4 book ai didi

ios - 我无法将视频上传到服务器

转载 作者:行者123 更新时间:2023-11-30 12:10:56 25 4
gpt4 key购买 nike

我尝试了一切,但每次尝试上传此视频时都会出现此错误。错误

Domain=NSCocoaErrorDomain Code=257 "The file “IMG_1773.MOV” couldn’t be opened because you don’t have permission to view it."

[![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 "The file “IMG_1773.MOV” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/var/mobile/Media/DCIM/101APPLE/IMG_1773.MOV, NSUnderlyingError=0x174254280 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

file:///var/mobile/Media/DCIM/101APPLE/IMG_1773.MOV

我需要帮助!!!

最佳答案

我在上传视频时遇到了同样的问题。对于云视频正在上传,但是对于手机内存中的视频则面临错误。对于不是来自云的视频,您需要做的就是使用 NSData,而不是使用 URL 路径。希望这有帮助。谢谢。

   [[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];
});
}
}];
}

关于ios - 我无法将视频上传到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46067028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com