I am using GoogleDrive API in my application to upload files from my application. So far I succeeded and finding good results for uploading all types of files.
I followed Google example to upload files.
I am trying to show the progress, dependent on file size, while uploading. I have gone through many classes in the google given example code but there isn't much result.
Steps followed to get the file uploading progress :
I have found below method In GTLServices.m
- (void)setUploadProgressBlock:(GTLServiceUploadProgressBlock)block {
  [uploadProgressBlock_ autorelease];
  uploadProgressBlock_ = [block copy];
  if (uploadProgressBlock_) {
    // As above, we need the fetcher to call us back when bytes are sent.
    SEL sentDataSel = @selector(objectFetcher:didSendBytes:totalBytesSent:totalBytesExpectedToSend:);
    [[self objectFetcher] setSentDataSelector:sentDataSel];
  }
}
After that in MyViewController.m written like this
 [self.driveService setUploadProgressBlock:^(GTLServiceTicket *ticket, unsigned long long numberOfBytesRead, unsigned long long dataLength) {
  NSLog(@"uploading");
 
}];
Above NSLog never getting excused because of this I am unable to get uploaded data bytes. By debugging I come across as uploadProgressBlock_ always showing nil. may be this resone my block handler not getting executed.
Please suggest me if I did any mistake to work it out. If any one have idea to get the bytes of data uploaded to google drive for a file please suggest me. Your suggestions are more useful to my work.
Thanks in advance.
Consolidated Answer by taking our folks suggestions:
Here is the code to get upload progress information
GTLServiceTicket *uploadTicket= [self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,GTLDriveFile *updatedFile,NSError *error)
        {
            if (error == nil)
            {
                [self.delegate completedFileUploadingToGoogleDrive];
                NSError *fileDeletionError=nil;
                [[NSFileManager defaultManager] removeItemAtPath:absalutePath error:&fileDeletionError];
            } else
            {
                [self.delegate errorOccoredWhileUploadingToGoogleDrive:error];
            }
        }];
        
        [uploadTicket setUploadProgressBlock:^(GTLServiceTicket *ticket, unsigned long long totalBytesWritten, unsigned long long totalBytesExpectedToWrite) {
            [self.delegate uploadedFileInfoInKB:(float)totalBytesExpectedToWrite/1024 and:(float)totalBytesWritten/1024];
        }];
Happy Coding!!
I have succeeded in using the upload block callback... assign it to the GTLServiceTicket object you obtain from the executeQuery method. 
Sample:
GTLServiceTicket *uploadTicket =  [self.driveService executeQuery:query  completionHandler:^(GTLServiceTicket *ticket,  GTLDriveFile *insertedFile, NSError *error) 
                                           { // completion 
                                           }];
        [uploadTicket setUploadProgressBlock:^(GTLServiceTicket *ticket, unsigned long long totalBytesWritten, unsigned long long totalBytesExpectedToWrite) 
         {
             // progress
         }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With