问题
Have the authorization part finished yet and works ok (no errors etc). After this I want to get the folders and files from the root of the drive. Starting first to get the files in the root (the procedure is rather similar to get the folders using children instead).
I have designed the following code (according to the google example that produces a similar result), this is a part of my drive class:
o.cdGetCloudFiles = function(fCallback, sFolderId )
{
var oDefQ = {q:'trashed=false', maxResults:1000, folderId:(typeof sFolderId == 'string')?sFolderId:'root'},
fGetFiles = function(request, result)
{
request.execute(function(resp)
{
if( resp.items instanceof Array )
{
result = result.concat(resp.items);
if( resp.nextPageToken )
{ // Get next file and 'break' this function
return fGetFiles(gapi.client.drive.files.list($j.extend(oDefQ,{'pageToken':resp.nextPageToken})), result);
}
}
fCallback(result.length?result:false);
});
};
fGetFiles(gapi.client.drive.files.list(oDefQ), []);
};
The original code can be found here: https://developers.google.com/drive/v2/reference/files/list
There are two files and one directory in the root of the drive:
[folder] Alice Deejay - Who Needs Guitars Anyway
[file] A day without rain.mp3
[file] Discobitch - C'est beau la bourgeoisie.mp3
The problem is that I don't get any files using the example above. When I change 'trashed=false'
into 'trashed=true'
then I get four deleted files (I previously delete from the drive).
Can somebody explain why I don't see/get any files? Also changed the rights to public but doesn't seems to make any difference.
回答1:
Same situation as following question: google drive api, javascript list files returns nothing
I needed to add to the scope the path 'drive
' at authorizing, I had only drive.file
which is intent to create/edit files only. The weird thing is that the API returns deleted files when you don't have permissions to view files, I think it's a bug in the API (a serious one).
Post this bug on google drive: https://productforums.google.com/forum/#!searchin/drive/security$20issue$20permission$20view/drive/pupjKxTz9FU/cUarGIl_Ah0J
来源:https://stackoverflow.com/questions/18178682/google-drive-get-root-file-and-folders-with-javascript-api-get-only-deleted