从iPhone应用程序打开谷歌驱动器文件时,下载URL具有空值

时间:2013-06-11 06:38:36

标签: google-drive-api xcode4.6

我正在使用谷歌驱动器sdk for iOS app.User应该能够从我们的应用程序打开文档。我正在尝试使用以下代码从我的Google云端硬盘下载文件 -

- (void)loadFileContent {

     UIAlertView *alert = [DrEditUtilities showLoadingMessageWithTitle:@"Loading file content" delegate:self];

GTMHTTPFetcher *fetcher =[self.driveService.fetcherService fetcherWithURLString:self.driveFile.downloadUrl];

[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {

if (error == nil) {

  NSString* fileContent = [[NSString alloc] initWithData:data
                                                encoding:NSUTF8StringEncoding];

  self.textView.text = fileContent;

  self.originalContent = [fileContent copy];

} else {

  NSLog(@"An error occurred: %@", error);

  [DrEditUtilities showErrorMessageWithTitle:@"Unable to load file" message:[error description] delegate:self];
}
}]; }

但是当我尝试下载Google文档文件时,下载网址的值为空。请帮帮我解决这个问题?

1 个答案:

答案 0 :(得分:3)

您无法获取Google文档文件的下载网址。它们只是保存在服务器中,您无法直接查看其内容。这与其他产品(如电子表格和演示文稿)相同。相反,您可以获得exportLinks。它将帮助您获取各种已知格式的文档,例如.doc或.pdf

如果您真的想要更好地控制Google文档,可以使用Google Apps脚本Document