我想使用谷歌驅動器API從我的谷歌驅動器獲取所有文件和文件夾名稱。如何獲取Google Drive API的文件夾和文件列表?
我的查詢是這樣的:
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = @"";
//or i also use this code
query.q = @"mimeType = 'text/plain'";
連我也試過這樣的代碼:
-(void)getFileListFromSpecifiedParentFolder {
GTLQueryDrive *query2 = [GTLQueryDrive queryForChildrenListWithFolderId:@"root"];
query2.maxResults = 1000;
// 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 = %@", file.originalFilename);
}];
}
}
}];
}
[這裏](https://developers.google.com/drive/v2/reference/children/list)如果你使用你會發現文件(包括目標C代碼段)和一個表單創建請求,並檢查正確的參數 – 2013-03-18 13:08:21
@ A-live它的幫助完整 – ios 2013-03-19 04:45:06
隨時自己回答或提供更多的細節。 – 2013-03-19 05:59:54