使用带有“orderBy”选项的查询按排序顺序列出文件/文件夹。
下面的“orderBy”标题不起作用。(参考:Google Drive Api 不按单词出现次数的降序返回结果)
function list_google_drive_contents(id, parent) {
gapi.client.load('drive', 'v2', function() {
function read_files(page_token, list) {
var request = gapi.client.drive.files.list(page_token);
console.log(page_token);
request.execute(function(resp) {
if(resp.items) {
list = list.concat(resp.items);
}
if(resp.nextPageToken) {
page_token.pageToken = resp.nextPageToken;
read_files(page_token, list);
} else {
handle_google_drive_file_list(list, parent);
}
});
}
var query = "'" + id + "' in parents";
read_files({'q' : query, 'orderBy' : 'title'}, []);
});
}
怎么了?
有关“orderBy”的更多信息: https ://developers.google.com/google-apps/documents-list/v2/reference