如何从GTLDriveFile获取网址到谷歌驱动器文件? [英] How to get url to google drive file from GTLDriveFile?
问题描述
在旧版Google云端硬盘API v2中,文件资源包含 alternateUrl
,可用于指向浏览器中的文件。在最新版本的Google云端硬盘v3中,文件资源仅包含 webViewLink
,但它返回 nil
。
也许有办法将文件标识符转换为url?
编辑:
如上所述类似的问题堆栈溢出,webViewLink只返回公共文件夹。作为我现在使用的解决方法:
[NSString stringWithFormat:@https://drive.google.com/file/ d /%@ / view,file.identifier]
但不确定这个网址是否有效在未来,完美的谷歌API会返回一些我可以用来稍后在浏览器中打开文件。在我的应用程序中,我的webViewLink 解析方案
有价值!
您必须在查询操作中添加以下代码 fileListQuery.fields = @*;
In old version of the Google Drive API v2 a fileresource contained was alternateUrl
which could be used to point to the file in browser. In latest version of Google Drive v3 a fileresource contains only webViewLink
, but it's returned nil
.
Maybe there is way to convert file identifier to url ?
Edit: As mentioned in similar question on stack overflow, the webViewLink is returned only for public folders. As a workaround i used for now:
[NSString stringWithFormat:@"https://drive.google.com/file/d/%@/view", file.identifier]
But not sure if this urls will be valid in future, perfectly google api would return something i could use to later open file in browser.
in my app, my webViewLink have value!
You must in query action add following codefileListQuery.fields = @"*";
这篇关于如何从GTLDriveFile获取网址到谷歌驱动器文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!