来自谷歌驱动器的客观c列表文件

Aso*_*n R 5 objective-c ios google-drive-api

我正在开发ios应用程序,包括谷歌驱动器.在谷歌驱动器中尝试列出文件时,它会在单页本身中显示所有文件夹,子文件夹和子文件.这些是我的代码

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];

    [driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                         GTLDriveFileList *filesList,
                                                         NSError *error) {
if (error == nil) {

            [FilesFromGoogleDrive addObjectsFromArray:filesList.items
             ];

        };
Run Code Online (Sandbox Code Playgroud)

我不想列出主页中的所有文件.我需要类似于谷歌驱动器应用程序以顺序方式访问文件夹,子文件夹,子文件.从过去一周尝试这个,但没有好结果.所以请帮我如何访问文件夹,子文件夹.

Cla*_*ino 5

如果要列出标识的文件夹中的所有文件folderId,可以使用以下代码(来自https://developers.google.com/drive/v2/reference/children/list):

+ (void)printFilesInFolderWithService:(GTLServiceDrive *)service
                             folderId:(NSString *)folderId {
  // The service can be set to automatically fetch all pages of the result. More
  // information can be found on https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Result_Pages.
  service.shouldFetchNextPages = YES;

  GTLQueryDrive *query =
    [GTLQueryDrive queryForChildrenListWithFolderId:folderId];
  // queryTicket can be used to track the status of the request.
  GTLServiceTicket *queryTicket =
    [service executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket,
                            GTLDriveChildList *children, NSError *error) {
          if (error == nil) {
            for (GTLDriveChildReference *child in children) {
              NSLog(@"File Id: %@", child.identifier);
            }
          } else {
            NSLog(@"An error occurred: %@", error);
          }
        }];
}
Run Code Online (Sandbox Code Playgroud)

另一种选择是搜索folderId其Parents集合中的文件:

https://developers.google.com/drive/search-parameters

例如,您可以拥有如下搜索查询:

'1234567' in parents
Run Code Online (Sandbox Code Playgroud)

其中'1234567'是您要为其列出文件的文件夹的ID.