无法将 Instagram 视频下载到相机胶卷

Cannot download Instagram video to camera roll

我正在尝试学习 Instagram API,我希望能够将图像和视频内容保存到我的相机胶卷中。到目前为止,图像代码工作正常,但我无法将视频保存到相机胶卷。到目前为止,这是我的代码

- (void)downloadButtonPressed:(UIButton *)sender {
if ([self.mediaModel.mediaType isEqualToString:@"video"]) {
    NSURL *videoURL = [NSURL URLWithString:_mediaModel.videoStandardResolutionURL];
    if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoURL.path)) {
        NSLog(@"compatible");
    } else {
        NSLog(@"not compatible");
    }
    //UISaveVideoAtPathToSavedPhotosAlbum(videoPath, nil, nil, nil);
} else {
    UIImageWriteToSavedPhotosAlbum(self.imageView.image, nil, nil, nil);
}

}

首先我检查媒体类型是不是视频。如果没有,那么图像很容易保存。

如果不是,我会检查 videoURL.path 是否兼容,但这是我卡住的地方,我得到这样的错误:

Video /hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4 cannot be saved to the saved photos album: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x7f8b48f25d00 {NSUnderlyingError=0x7f8b48f39f90 "The operation couldn’t be completed. No such file or directory", NSErrorFailingURLStringKey=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSErrorFailingURLKey=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSURL=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSLocalizedDescription=The requested URL was not found on this server.}

非常感谢您的帮助。非常感谢!

不要尝试直接从网络上保存到已保存的相册中。下载它(使用 NSURLSession 和下载任务)。然后从那里(即从本地文件URL,这给你)保存到保存的相册。