如何获得Google Drive文件的公开网址? [英] How to get Public Url of the Google Drive Files?

查看:338
本文介绍了如何获得Google Drive文件的公开网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取可以在任何地方进行流式传输的公开网址。我可以获取 downloadUrl ,但对 exportLinks 执行相同操作会产生空值。代码如下,但我不知道我的问题是什么。

  NSError * error; 
NSString * exportURLStr;
GTLDriveFile * file = [driveFiles objectAtIndex:indexPath.row];
exportURLStr = [NSString stringWithFormat:@%@,file.exportLinks];
NSURL * url = [NSURL URLWithString:exportURLStr];
NSString * temp1 = [NSString stringWithFormat:@%@,url];

// temp1的NSLog为空
//我用file.WebContentLink试过但得到404错误

这只是代码的一小部分,所以如果我需要展示更多的内容,就问一下。

div>

通过 google-api-objectivec-client 转至 DriveSampleWindowController.m



检查名为 - (void)downloadFormatSelected的方法:(NSMenuItem *)menuItem 显示如何格式化 exportLinks

  NSLog(@%@,[file.exportLinks JSONValueForKey:@urtitlekey]); 

这就是你想要的。希望它有帮助。


I'm trying to get a public url that can be accessed anywhere for streaming. I can get the downloadUrl, but doing the same for exportLinks results in null values. The code for this is below, though I don't know what my problem is.

NSError *error;
NSString *exportURLStr;  
GTLDriveFile *file = [driveFiles objectAtIndex:indexPath.row];
exportURLStr = [NSString stringWithFormat:@"%@",file.exportLinks];  
NSURL *url = [NSURL URLWithString:exportURLStr];
NSString *temp1= [NSString stringWithFormat:@"%@",url];

// NSLog of temp1 is Null
// I tried with file.WebContentLink  but getting 404 Error

This is only a snippet of the code, so if I need to show more, just ask.

解决方案

From google-api-objectivec-client go to DriveSampleWindowController.m,

check the method called - (void)downloadFormatSelected:(NSMenuItem *)menuItem where its shown cleary how to format the exportLinks.

 NSLog(@"%@",[file.exportLinks JSONValueForKey:@"urtitlekey"]); 

This is what you wanted.Hope it helps.

这篇关于如何获得Google Drive文件的公开网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆