我想从谷歌硬盘下载或导出文件。
- (BOOL)webView:(UIWebView *)awebView shouldStartLoadWithRequest:(NSURLRequest *)请求navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
GTMHTTPFetcher *fetcher =
[self.driveService.fetcherService fetcherWithURLString:@"Google Drive file Url"];
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error)
{
if (error == nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"dream.mp3"];
[data writeToFile:filePath atomically:YES];
}
else
{
NSLog(@"An error occurred: %@", error);
}
}];
}
}