我想使用谷歌驱动器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