iOS 怎么下载视频文件

纯新手一个,第一次用AVOS

我是这样上传视频的:

//得到拍摄视频
        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
        //写入文档
        NSData *videoData = [NSData dataWithContentsOfURL:videoURL];
        uploadFile = [AVFile fileWithName:@"video.mp4" data:videoData];
        [uploadFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
            NSLog(@"成功 %d",succeeded);
        } progressBlock:^(NSInteger percentDone) {
             NSLog(@"%ld",(long)percentDone);
        }];

到了下载的时候,直接崩掉了,那个下载的AVFile应该怎么初始化呢? 看文档我只能理解根据objectId下载了

这是我想下载并得到下载进度的代码:

NSDictionary *dict = @{@"download": videoID};      //videoID就是上传那个AVFILE的objectId  
NSLog(@"objectId: %@",[dict objectForKey:@"download"]);

AVFile *downloadFile = [dict objectForKey:@"download"];
[downloadFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
    NSLog(@"123");
} progressBlock:^(NSInteger percentDone) {
    NSLog(@"%ld",(long)percentDone);
}];

本人太新手了。。 搜问题也没搜到类似问题的, 厚脸皮自己发帖问一下好了。。在线等 - -

阅读 9.2k
1 个回答
新手上路,请多包涵

问题解决了- -
在此之前要先
[AVFile getFileWithObjectId:videoID withBlock:^(AVFile *file, NSError *error)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进