【发布时间】:2013-03-18 12:01:05
【问题描述】:
我想使用 google drive API 从我的 google drive 中获取所有文件和文件夹名称。
我的查询是这样的:
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);
}];
}
}
}];
}
【问题讨论】:
标签: ios objective-c google-drive-api