2

다음 방법을 사용하여 하위 폴더를 가져올 수 있지만이 코드는 루트에서 모든 폴더를 검색합니다. 예를 들어 휴지통에 폴더가있는 경우 내 드라이브의 폴더와 함께 검색합니다.Google 드라이브에서 내 드라이브의 하위 폴더를 가져 오는 방법

내 요구 사항은 폴더가 내 드라이브에 없으면 먼저 폴더를 만들고 파일을 삽입해야한다는 것입니다. 내 문제는, 폴더 이름을 확인할 때 폴더가 휴지통에 있지만 내 드라이브에는 존재하지 않기 때문에 폴더가 존재할 때 응답을 얻고 있습니다.

다음은 폴더를 검색하는 방법입니다.

누군가에게 아이디어가 있으면 알려 주시기 바랍니다.

-(void)getFileListFromSpecifiedParentFolder { 
    GTLQueryDrive *query2 = [GTLQueryDrive queryForFilesList]; 
// GTLQueryDrive *query2 = [GTLQueryDrive queryForChildrenListWithFolderId:@"My Drive"]; 

    query2.q = @""; 
    //or i also use this code 

    query2.q = @"mimeType = 'application/vnd.google-apps.folder'"; 

    // queryTicket can be used to track the status of the request. 
    [self.driveService executeQuery:query2 
        completionHandler:^(GTLServiceTicket *ticket, 
             GTLDriveChildList *children, NSError *error) { 
         NSLog(@"\nGoogle Drive: file count in the folder: %d", children.items.count); 
         //incase there is no files under this folder then we can avoid the fetching process 
         if (!children.items.count) { 
          return ; 
         } 

         if (error == nil) { 
          for (GTLDriveChildReference *child in children) { 

           GTLQuery *query = [GTLQueryDrive queryForFilesGetWithFileId:child.identifier]; 

           // queryTicket can be used to track the status of the request. 
           [self.driveService executeQuery:query 
              completionHandler:^(GTLServiceTicket *ticket, 
                   GTLDriveFile *file, 
                   NSError *error) { 

               NSLog(@"\nfile name = %@ \n file kind %@ \n file identifier %@", file.title,file.kind,file.identifier); 
              }]; 
          } 
         } 
         else 
          [self createFolderForGoogleDriveWithName:@"Music"]; 
        }]; 
} 

답변

3

할 수 있습니다 다음과 같은 쿼리를 휴지통에 디렉토리를 필터링 : application/vnd.google-apps.folder' and trashed = false