我是xcode开发的全新手。但是我正在为一个uni项目做这件事。 我需要从Dropbox下载一个已上传到我帐户的视频。
我设法在前一个问题的帮助下流式传输它。但是,我似乎无法下载视频。我可以在另一方面下载zip文件等。我的URL是错的,不能从DropBox下载? 要下载我使用AFNetworking
-(IBAction)download{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:@"https://dl.dropboxusercontent.com/s/0c163kau6u2smyd/HXH2011_1.mp4"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
NSURL *documentsDirectoryPath = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]];
return [documentsDirectoryPath URLByAppendingPathComponent:[targetPath lastPathComponent]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
NSLog(@"File downloaded to: %@", filePath);
}];
[downloadTask resume];
}
http://example.com/download.zip工作正常
我也试过https://dl.dropboxusercontent.com/s/0c163kau6u2smyd/HXH2011_1.mp4?=dl