node.js - Node : Google Drive API for listing all files using query

标签 node.js google-api google-drive-api

我想知道如何使用 GoogleAPIS 库查询 Google 云端硬盘中的所有文件

https://github.com/google/google-api-nodejs-client/

我不知道如何使用这个库!

我不知道应该在哪里放置查询,我已经尝试了下面的代码,但没有得到任何响应..

测试1:

drive.files.list("mimeType='image/jpg'", function(data){
    //I am getting all the data, the query is not working..
));

测试2:

drive.files.list({
    media: {
        mimeType: 'application/vnd.google-apps.folder'
    }
}, function(err, data){
    //I am getting all the data, the query is not working..
});

测试3:

drive.files.list({
    resource: {
        mimeType: 'application/vnd.google-apps.folder'
    }
}, function(err, data){
    //This returns error not working at all!
});

最佳答案

您可以检查此处给出的drive.files.list函数https://github.com/google/google-api-nodejs-client/blob/master/apis/drive/v2.js#L733并使用类似以下内容的内容。

var drive = google.drive({ version: 'v2', auth: oauth2Client });
drive.files.list({
   q='mimeType='image/jpg''
 }, callback);

有关列表函数的输入参数的更多详细信息,请参见 https://developers.google.com/drive/v2/reference/files/list

关于node.js - Node : Google Drive API for listing all files using query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26781324/

相关文章:

javascript - Node 和套接字聊天应用程序 - 仅显示 25 条最近消息

JavaScript/Node + cURL

php - 客户端无权使用此方法检索访问 token - Google calendar php api

python - Youtube API 请求凭据

javascript - Google Drive NodeJS api返回已删除的文件

javascript - 丢失全局变量值

node.js - 在 Nightwatch 命令队列中使用 REST 客户端

c# - 请求的身份验证范围不足。 [403]。谷歌人员API

android - Google Drive 从文件夹中获取文件

ios - iOS 和 "invalid_grant"上的 Google 云端硬盘