Google Drive iOS SDK: Free User Space Access

I am creating an app that uses the iOS Google Drive SDK to upload files to a Google Drive user account. Due to the size of the uploaded files, I would like to know how much space the user has and is available. For example, I plan on having a label in my application that shows the user is currently using 10gb / 100gb.

I guess there might be a way to grab this information from the initial login, but I would like to get this information on the fly.

Thanks in advance!

+3


source to share


1 answer


You can request the About resource to get this information. The docs for this include also sample code: https://developers.google.com/drive/v2/reference/about/get



#import "GTLDrive.h"
// ...

+ (void)printAboutWithService:(GTLServiceDrive *)service {
  GTLQueryDrive *query = [GTLQueryDrive queryForAboutGet];
  // queryTicket can be used to track the status of the request.
  GTLServiceTicket *queryTicket =
    [service executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket, GTLDriveAbout *about,
                            NSError *error) {
          if (error == nil) {
            NSLog(@"Current user name: %@", about.name);
            NSLog(@"Root folder ID: %@", about.rootFolderId);
            NSLog(@"Total quota (bytes): %@", about.quotaBytesTotal);
            NSLog(@"Used quota (bytes): %@", about.quotaBytesUsed);
          } else {
            NSLog(@"An error occurred: %@", error);
          }
        }];
}

// ...

      

+7


source







All Articles