2

I am working on google client Api V3 for uploading files from my IOS Application. The Scopes I have used are

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

The code I used for uploading a new file is

  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);
}];

The problem is web content link is null and want it in response to store it in my database because my web App will use this link to open that file.

Previous version of google drive api was returning web content link. How can I get Web Content Link?

Hassan Malik
  • 559
  • 6
  • 20
  • 2
    Check this documentation: [Migrate to Google Drive API v3](https://developers.google.com/drive/v3/web/migration). Be noted that full resources are no longer returned by default. Use the `fields` query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are return. You may check this [sample](https://developers.google.com/drive/ios/devguide/files#creating_new_files) for reference. – abielita Nov 08 '16 at 10:02
  • thanks a lot for help. – Hassan Malik Nov 08 '16 at 13:33
  • I'll post this as an answer. You may upvote/accept it if it helps! :) – abielita Nov 08 '16 at 13:49

1 Answers1

4

Check this documentation: Migrate to Google Drive API v3. Be noted that full resources are no longer returned by default. Use the fields query parameter to request specific fields to be returned. If left unspecified only a subset of commonly used fields are return. You may check this sample for reference.

abielita
  • 13,147
  • 2
  • 17
  • 59