在将新文件上传到云端硬盘后,Google云端硬盘Api V3未返回Web Content链接?
问题描述:
我正在从谷歌客户端Api V3上传我的IOS应用程序中的文件。 我已经使用的范围是在将新文件上传到云端硬盘后,Google云端硬盘Api V3未返回Web Content链接?
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);
}];
的问题是网站内容链接为空,并希望它在反应将其存储在我的数据库因为我的网络应用程序将使用此链接来打开该文件。
以前版本的google驱动api正在返回web内容链接。 如何获取Web Content Link?
答
查阅此文件:Migrate to Google Drive API v3。请注意,完整的资源不再被默认返回。使用fields
查询参数来请求返回特定字段。如果未指定,则只返回常用字段的子集。您可以检查此sample以供参考。
请查阅此文档:[迁移到Google Drive API v3](https://developers.google.com/drive/v3/web/migration)。请注意,完整的资源不再被默认返回。使用'fields'查询参数来请求返回特定的字段。如果未指定,则只返回常用字段的子集。您可以查看此[示例](https://developers.google.com/drive/ios/devguide/files#creating_new_files)以供参考。 – abielita
非常感谢您的帮助。 –
我会将其作为答案发布。如果它有帮助,你可以upvote /接受它! :) – abielita