查找共享文件夹Google Drive的所有者

时间:2016-08-29 23:40:19

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

在查找并找到与给定名称匹配的共享文件夹后,我需要知道该文件夹的创建者/所有者是否是特定的Google帐户。如何利用Google Drive的Objective-C SDK实现这一目标。

这是我的查询,它找到了名称的共享文件夹:

GTLQueryDrive *queryDrive = [GTLQueryDrive queryForFilesList];
queryDrive.q = @"mimeType='application/vnd.google-apps.folder' and trashed=false";

    [self.service executeQuery:queryDrive completionHandler:^(GTLServiceTicket *ticket,
                                                              GTLDriveFileList *files,
                                                              NSError *error) {
        if (error == nil)
        {
            NSString *identifier = @"";
            for(GTLDriveFile *file in files.files)
            {
                NSArray *tempArray = [NSArray arrayWithArray:file.owners];
                NSLog(@"File Title:  %@ | ID: %@",file.name , file.identifier);
                if ([file.name isEqualToString:@"GIVEN FOLDER NAME"]) {
                    identifier = file.identifier;

                        //How to know if the found folder is owned by a specified email?

                    break;

                }
            }
            if ([identifier isEqualToString:@""]) {
                [UISpinningWheelController removeSpinningWheel:self.view];
                [self showAlertWithTitle:@"Error" andMessage:@"The required folder has not been shared with this Google account. Please contact the administrator."];
            }
        }
        else {
            [UISpinningWheelController removeSpinningWheel:self.view];
            [self showAlertWithTitle:@"Error" andMessage:[error localizedDescription]];
        }
    }];

非常感谢你的帮助。

0 个答案:

没有答案