0
我正在從谷歌客戶端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?
請查閱此文檔:[遷移到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