【问题标题】:Google Drive iOS SDK: Getting user's space available [closed]Google Drive iOS SDK:获取用户可用空间[关闭]
【发布时间】:2013-02-06 02:44:15
【问题描述】:

我正在构建一个应用,它使用 Google Drive iOS SDK 将文件上传到用户的 Google Drive 帐户。由于正在上传的文件的大小,我想知道用户正在使用和有多少可用空间。例如,我计划在我的应用中添加一个标签,显示用户当前正在使用 10gb/100gb。

我猜可能有一种方法可以从初始登录中获取此信息,但我想即时获取此信息。

提前致谢!

【问题讨论】:

    标签: ios objective-c google-drive-api


    【解决方案1】:

    您可以查询 About 资源以获取此信息。这方面的文档也包括一些示例代码: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);
              }
            }];
    }
    
    // ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-22
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多