Google驱动器:使用javascript api获取(根)文件和文件夹(仅在驱动器上获取已删除的文件) [英] Google drive: Get (root) file and folders with javascript api (get only deleted files on drive)

查看:112
本文介绍了Google驱动器:使用javascript api获取(根)文件和文件夹(仅在驱动器上获取已删除的文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

授权部分尚未完成并可正常工作(无错误等)。在此之后,我想从驱动器的根目录获取文件夹和文件。首先开始获取根文件(该过程非常类似于使用儿童获取文件夹)。



我设计了以下代码(根据google这是我的驱动器类的一部分:

  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)
{//获取下一个文件和'break'这个函数
返回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),[]);
};

原始代码可以在这里找到: https://developers.google.com/drive/v2/reference/files/list

驱动器根目录中有两个文件和一个目录:

  [文件夹] Alice Deejay  - 无论如何谁需要吉他
[file]一天没有rain.mp3
[file] Discobitch - C'est beau la bourgeoisie.mp3

问题是我没有使用上面的示例获取任何文件。当我将'trashed = false'更改为'trashed = true'时,我得到了四个已删除的文件从驱动器)。

有人可以解释为什么我没有看到/得到任何文件吗?

解决方案

与以下问题相同的情况:
谷歌驱动api,javascript列表文件不会返回任何内容
a>



我需要在作用域中添加路径'驱动器',我只有 drive.file 它只是为了创建/编辑文件。奇怪的是,当你没有查看文件的权限时,API返回被删除的文件,我认为这是API中的一个错误(一个严重的错误)。



在谷歌驱动器上发布此错误:
https://productforums.google .com / forum /#!searchin / drive / security $ 20issue $ 20permission $ 20view / drive / pupjKxTz9FU / cUarGIl_Ah0J


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.

解决方案

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

这篇关于Google驱动器:使用javascript api获取(根)文件和文件夹(仅在驱动器上获取已删除的文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆