3
我在构建一款应用程序,该应用程序使用Google Drive iOS SDK将文件上传到用户的Google云端硬盘帐户。由于上传文件的大小,我想知道用户有多少空间可用。例如,我计划在我的应用中添加一个标签,显示用户当前正在使用10gb/100gb。Google Drive iOS SDK:获取用户空间
我猜测可能有一种方法可以从初始登录中获取此信息,但我希望能够即时获取此信息。
在此先感谢!
我在构建一款应用程序,该应用程序使用Google Drive iOS SDK将文件上传到用户的Google云端硬盘帐户。由于上传文件的大小,我想知道用户有多少空间可用。例如,我计划在我的应用中添加一个标签,显示用户当前正在使用10gb/100gb。Google Drive iOS SDK:获取用户空间
我猜测可能有一种方法可以从初始登录中获取此信息,但我希望能够即时获取此信息。
在此先感谢!
您可以查询关于资源以获取此信息。此文档还包含一些示例代码: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);
}
}];
}
// ...