2013-02-06 118 views
3

我在構建一款應用程序,該應用程序使用Google Drive iOS SDK將文件上傳到用戶的Google雲端硬盤帳戶。由於上傳文件的大小,我想知道用戶有多少空間可用。例如,我計劃在我的應用中添加一個標籤,顯示用戶當前正在使用10gb/100gb。Google Drive iOS SDK:獲取用戶空間

我猜測可能有一種方法可以從初始登錄中獲取此信息,但我希望能夠即時獲取此信息。

在此先感謝!

回答

7

您可以查詢關於資源以獲取此信息。此文檔還包含一些示例代碼: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); 
      } 
     }]; 
} 

// ...