我想从远程URL下载视频并将其保存到iPhone应用程序中的文件中。 我知道视频链接的作品,因为我用AVPlayer,但是,我无法下载它。答复总是(空)。iOS - 下载视频
以下代码有什么问题?
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:someURLString]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:someFilePath append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully downloaded file to %@", [NSURL fileURLWithPath:someFilePath]);
NSLog(@"THE RESPONSE: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation start];
更新
我注释掉operation.outputStream线,而这一次我得到了响应。这是否意味着文件路径有问题?
是否下载文件? – 2013-07-21 06:21:32
不,操作总是“成功”,但没有下载任何东西@ H2CO3 – GangstaGraham
您是否试图将它下载到应用程序包中? – 2013-07-21 06:26:03