如何使用 Google Drive API Javascript 列出特定文件夹中的更改
How to list changes in a specific folder using Google Drive API Javascript
我正在使用 Changes:list API 列出更改。
https://developers.google.com/drive/api/v3/reference/changes/list
但结果包括我驱动器中的所有文件夹。我想过滤特定文件夹的结果。在文档中,我没有看到像“Files:List”那样的“changes:list”参数“q”。
有没有办法通过 API 参数过滤结果?或者我是否需要使用我已经知道的“文件夹 ID”在我的代码中执行此操作?
这是我正在使用的代码:
var request = gapi.client.drive.changes.list({
//The collection works by providing the current state of each item, if and only if the item has changed since a given point in time.
//point in history to retrive changes, we can saved this to know if there are changes
pageToken: '820167',
//test parameters that are not working
//q: "'12pDb31bRw7p3pfJoF_N6VncDqISSY1W4' in parents",
//q: 'trashed=false and "'+ folderId +'" in parents',
fields: '*',
pageSize: 5,
orderby:'title',
maxResults: 50
});
request.execute(function (resp) {
console.log(resp);
});
我可能建议改用 Drive Activity API,这样您就可以查询文件夹中的更改。您需要指定参数 ancestorName=items/${folderId}
。 Drive Activity 还将让您更深入地了解实际发生的 activity。
驱动器更改资源非常少。它旨在快速查看整个驱动器/共享驱动器的变化。它增加的价值是能够设置推送通知监视 - 这些可用于触发进一步的操作。
不幸的是,Changes: list
方法无法实现您想要的 returns 用户或共享驱动器的更改列表。
因此,如果您想检索特定文件夹的更改,则必须事后在您的代码中以编程方式过滤它们。
您还可以在 Google 的问题跟踪器 here 上提交 功能请求 并提供所有必要的详细信息。
参考
我正在使用 Changes:list API 列出更改。
https://developers.google.com/drive/api/v3/reference/changes/list
但结果包括我驱动器中的所有文件夹。我想过滤特定文件夹的结果。在文档中,我没有看到像“Files:List”那样的“changes:list”参数“q”。
有没有办法通过 API 参数过滤结果?或者我是否需要使用我已经知道的“文件夹 ID”在我的代码中执行此操作?
这是我正在使用的代码:
var request = gapi.client.drive.changes.list({
//The collection works by providing the current state of each item, if and only if the item has changed since a given point in time.
//point in history to retrive changes, we can saved this to know if there are changes
pageToken: '820167',
//test parameters that are not working
//q: "'12pDb31bRw7p3pfJoF_N6VncDqISSY1W4' in parents",
//q: 'trashed=false and "'+ folderId +'" in parents',
fields: '*',
pageSize: 5,
orderby:'title',
maxResults: 50
});
request.execute(function (resp) {
console.log(resp);
});
我可能建议改用 Drive Activity API,这样您就可以查询文件夹中的更改。您需要指定参数 ancestorName=items/${folderId}
。 Drive Activity 还将让您更深入地了解实际发生的 activity。
驱动器更改资源非常少。它旨在快速查看整个驱动器/共享驱动器的变化。它增加的价值是能够设置推送通知监视 - 这些可用于触发进一步的操作。
不幸的是,Changes: list
方法无法实现您想要的 returns 用户或共享驱动器的更改列表。
因此,如果您想检索特定文件夹的更改,则必须事后在您的代码中以编程方式过滤它们。
您还可以在 Google 的问题跟踪器 here 上提交 功能请求 并提供所有必要的详细信息。