即使经过过滤,Google Picker 也会显示指向不属于我的文件的快捷方式 AFAIK,目前不可能功能请求解决方法

问题描述

我正在使用驱动器 Picker Api 并在网页中制作驱动器选择器。我只显示用户拥有的驱动器文件或项目(相当于使用查询作为 owner="me")。

现在我在选择器中遇到一个问题:它还显示用户不是所指向文件的所有者的文件或项目的快捷方式。

我需要显示用户拥有的文件。要么通过一种方式来过滤所有快捷方式,要么理想情况下仅包含用户是所有者的文件或项目的快捷方式。

这是所有者文件选择器的示例代码

//The API developer key obtained from the Google Cloud Console.
var developerKey = "{developerkey value}";

// The Client ID obtained from the Google Cloud Console.
var clientId = "{clientId value}";

// Scope to use to access user's Drive.
var scope = [
  "https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/userinfo.email",];

var pickerApiLoaded = false;
var oauthToken;

// Use the API Loader script to load google.picker and gapi.auth

function onApiLoad() {
  gapi.load("auth",{ callback: onAuthApiLoad });
  gapi.load("picker",{ callback: onPickerApiLoad });
}

function onAuthApiLoad() {
  window.gapi.auth.authorize(
    {
      client_id: clientId,scope: scope,immediate: false,},handleAuthResult
  );
}

function onPickerApiLoad() {
  pickerApiLoaded = true;
  createPicker();
}

function handleAuthResult(authResult) {
  if (authResult && !authResult.error) {
    oauthToken = authResult.access_token;
    createPicker();
  }
}
// Create and render a Picker object.
function createPicker() {
  var DocsView = new google.picker.DocsView(
    google.picker.ViewId.DOCS
  ).setownedByMe(true);
  var picker = new google.picker.PickerBuilder()
    .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
    .enableFeature(google.picker.Feature.SUPPORT_DRIVES)
    .addView(DocsView)
    .addView(new google.picker.DocsuploadView())
    .setDeveloperKey(developerKey)
    .setoAuthToken(oauthToken)
    .setCallback(pickerCallback)
    .build();
  picker.setVisible(true);
}

你能帮我吗?如何在 Picker 中排除快捷方式或显示用户是其所有者的快捷方式。

解决方法

AFAIK,目前不可能

即使你使用这样的东西:

view.setQuery('owner="me"')

这仍将返回您创建的所有快捷方式,即使指向的文件不属于您。这是因为快捷方式是它们自己的 MIME 类型:

application/vnd.google-apps.shortcut

Source

功能请求

如果您在 Picker 上需要此功能,则需要使用此模板提交功能请求:

Picker Feature Request

如果您确实提交了功能请求,请务必返回并在此处发布,以便其他人可以通过“加注”请求来投票。

此外,如果您提交文件,请务必包含示例,以及尽可能多的背景和理由,这将为其提供最佳实施机会。

解决方法

我相信您需要基于 Drive API 开发自己的 JS 选择器才能对快捷方式进行这种细粒度的控制。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...