[英]Accessing files in a folder via Drive API?
I am trying to access some files from my Google Drive, via the Drive API. 我正在尝试通过Drive API从我的Google Drive访问一些文件。 I followed the tutorial here , to do so in Javascript.
我按照此处的教程进行操作,以Java语言实现。 Now, simply calling the function
listFiles()
works correctly, and prints all the files in my drive, along with their ID's. 现在,只需调用函数
listFiles()
正常工作,并打印驱动器中的所有文件及其ID。
But, I want to access all the files found in certain folders. 但是,我想访问某些文件夹中的所有文件。 Looking online, the drive API has such a function called
retrieveAllFilesInFolder(folderId, callback)
在线查看时,驱动器API具有一个称为
retrieveAllFilesInFolder(folderId, callback)
的函数。
It is defined as follows: 定义如下:
function retrieveAllFilesInFolder(folderId, callback) {
var retrievePageOfChildren = function(request, result) {
request.execute(function(resp) {
result = result.concat(resp.items);
var nextPageToken = resp.nextPageToken;
if (nextPageToken) {
request = gapi.client.drive.children.list({
'folderId' : folderId,
'pageToken': nextPageToken
});
retrievePageOfChildren(request, result);
} else {
callback(result);
}
});
}
var initialRequest = gapi.client.drive.children.list({
'folderId' : folderId
});
retrievePageOfChildren(initialRequest, []);
}
When, I call the code in my local server (passing in a string ID of a folder), I get the following error: quickstart.html:73 Uncaught TypeError: Cannot read property 'list' of undefined
, implying there are no children of this folder. 当我在本地服务器中调用代码(传递文件夹的字符串ID)时,出现以下错误:
quickstart.html:73 Uncaught TypeError: Cannot read property 'list' of undefined
,这意味着没有子级的这个文件夹。 I know this to be false. 我知道这是错误的。 Is there a particular reason that this is happening.
是否有发生这种情况的特殊原因。
您可以通过Google Developers网站直接在此处进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.