ios - 将新文件上传到云端硬盘后,Google Drive Api V3 未返回 Web 内容链接?

标签 ios google-drive-api google-client google-api-objc-client

我正在开发 google 客户端 Api V3,用于从我的 IOS 应用程序上传文件。 我使用的范围是

NSArray *scopes = [NSArray arrayWithObjects:kGTLAuthScopeDrive,kGTLAuthScopeDriveFile,kGTLAuthScopeDriveAppdata,kGTLAuthScopeDriveMetadata, nil];

我用于上传新文件的代码是

  GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:file.mimeType];
                    GTLQuery * query = [GTLQueryDrive queryForFilesCreateWithObject:metadata uploadParameters:uploadParameters];
                                            GTLServiceTicket *uploadTicket=[self.gogService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                                                                           GTLDriveFile *updatedFile,
                                                                                                           NSError *error) {
 if (error == nil) {
        NSLog(@"File WebContent Link %@", [updatedFile webViewLink]);
}
else {
        NSLog(@"An error occurred: %@", [error localizedDescription]);
 }
 }];
[uploadTicket setUploadProgressBlock:^(GTLServiceTicket *ticket, unsigned long long totalBytesWritten, unsigned long long totalBytesExpectedToWrite)
{
       progressBar.progress=(1.0*totalBytesWritten/(1.0*totalBytesExpectedToWrite)) ;
       NSLog(@"%llu",totalBytesWritten);
       NSLog(@"%llu",totalBytesExpectedToWrite);
}];

问题是 Web 内容链接为空,并且希望它作为响应将其存储在我的数据库中,因为我的 Web 应用程序将使用此链接打开该文件。

以前版本的 Google Drive api 返回网页内容链接。 我如何获得网页内容链接?

最佳答案

查看此文档:Migrate to Google Drive API v3 。请注意,默认情况下不再返回完整资源。使用 fields 查询参数请求返回特定字段。如果未指定,则仅返回常用字段的子集。您可以查看这个sample供引用。

关于ios - 将新文件上传到云端硬盘后,Google Drive Api V3 未返回 Web 内容链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40470566/

相关文章:

ios - 如何在iOS中实现AFNetworking集成?

Python:使用 url 从谷歌驱动器下载文件

php - Google Analytics API 如何检索下一页数据

php 谷歌广告 api - unauthorized_client

android - Google 登录 tokenId 是 invalid_token

objective-c - 我应该使用什么 UIApplication Delegate

ios - 如何将 UISegmentedControl 绑定(bind)到 ViewModel 命令?

iphone - Firefox SQLite Manager无法访问Xcode iPhone模拟器SQLite DB目录

ruby - 使用 API 将 Google 幻灯片中的一张幻灯片复制到新的演示文稿中

python - 我存储了刷新 token ,如何使用它来刷新我的访问 token