【发布时间】:2013-08-08 06:37:51
【问题描述】:
您好,我正在从 Google 云端硬盘下载一个 3 MB 的媒体文件。文件在 82 kb 后完成下载。它没有完全下载。我检查了小文件..但是对于任何大小的文件,下载大小保持不变..即 82 kb..
我正在尝试使用 GTMHTTPFetcher 下载..但出现错误
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
GTLDriveFile *file;
NSString *downloadedString = file.downloadUrl; // file is GTLDriveFile
NSLog(@"%@",file.downloadUrl);
GTMHTTPFetcher *fetcher = [self.driveService.fetcherService fetcherWithURLString:downloadedString];
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error)
{
if (error == nil)
{
if(data != nil)
{
GTLDriveFile *file = [driveFiles objectAtIndex:indexPath.row];
filename=file.title;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
filename = [[paths objectAtIndex:0]stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileNames]];
NSData* Data = [[NSData alloc]initWithContentsOfURL:targetURL];
[Data writeToFile:filename atomically:YES];
NSLog(@"my path:%@",filename);
}
}
else
{
NSLog(@"Error - %@", error.description);
}
}];
// from the above code error is **Domain=com.google.GTMHTTPFetcher Code=-1 "The operation couldn’t be completed. (com.google.GTMHTTPFetcher error -1.)"**
【问题讨论】:
-
文件的内容是什么?您不使用某种身份验证来访问此文件吗?
-
文件的内容是音频,大小是 3 MB..我已经在表格视图中验证并列出了文件..从那里我正在下载..
-
失败了吗?你检查过 - (void)connection:(NSURLConnection *)aConn didFailWithError:(NSError *)error 吗?
-
@zahreelay...我没有收到任何错误...我用过这个方法
-
@LoïsDiQual ...我正在尝试下载 50 kb 的文件而不是显示 80 kb 的问题是什么
标签: ios google-drive-api google-api-objc-client