Google云端硬盘选择器:与Feature.SUPPORT_DRIVES一起使用Feature.MINE_ONLY [英] Google Drive Picker: Use Feature.MINE_ONLY along with Feature.SUPPORT_DRIVES

查看:77
本文介绍了Google云端硬盘选择器:与Feature.SUPPORT_DRIVES一起使用Feature.MINE_ONLY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个显示以下视图的Google云端硬盘选择器:

I am trying to create a Google Drive Picker that displays the following views:

  1. 一个文件夹"视图,显示当前用户的文件夹树,使他只能选择当前用户拥有的文件

  1. A "folder" view, displaying the folder tree of the current user, allowing him to only pick files that the current user owns

一个最近"视图,显示当前用户拥有的最新打开的文件

A "recent" view, displaying the latest opened files, that the current user owns

共享驱动器"视图(注:以前称为团队驱动器"),显示当前用户可以访问的共享驱动器(他不是文件的所有者,因为共享驱动器文件由所有者拥有)用户的G Suite平台)

A "shared drives" view (note: previously named "team drives"), displaying the current user's shared drives that he has access to (he his not owner of the files, as shared drives files are owned by the G Suite platform of the user)

首次尝试: Feature.MINE_ONLY Feature.SUPPORT_DRIVES

First attempt: Feature.MINE_ONLY with Feature.SUPPORT_DRIVES

我尝试做的第一件事是在 PickerBuilder 上同时启用 MINE_ONLY SUPPORT_DRIVES 这两个功能,但是这会导致共享驱动器"视图为空,因为用户不是共享驱动器中文件的所有者(请参见上面的说明).

The first thing I tried was to enable both features MINE_ONLY and SUPPORT_DRIVES on the PickerBuilder, however it causes the "shared drives" view to be empty, because the user is not owner of the files in shared drives (see explanation above).

第二次尝试: Features.SUPPORT_DRIVE + setOwnedByMe(true)

Second attempt: Features.SUPPORT_DRIVE + setOwnedByMe(true)

我尝试的第二件事是仅启用 SUPPORT_DRIVES 功能,并在文件夹"和最近"视图上使用 setOwnedByMe(true)方法.

The second thing I tried was to only enable the SUPPORT_DRIVES feature, and use the setOwnedByMe(true) method on "folder" and "recent" views.

几乎可以按预期工作,但是文件夹"视图未显示文件夹,因为 setOwnedByMe 函数无法与 setIncludeFolders 视图一起调用(参考).

It almost works as expected, BUT the "folder" view is not displaying folders, because the setOwnedByMe function cannot be called along with the setIncludeFolders view (reference).

以下是我第二次尝试的代码的简化版本(我故意未放入身份验证代码):

Following is a simplified version of my code for the second attempt (I intentionally did not put the authentication code):

var googlePicker = new google.picker.PickerBuilder();

// KO: DOES NOT DISPLAY THE FOLDERS
var folderView = new google.picker.DocsView().
    //setIncludeFolders(true). // -> cannot be used with setOwnedByMe, else it overrides it
    setOwnedByMe(true).
    setParent('root');

// OK
var recentFilesView = new google.picker.DocsView(google.picker.ViewId.DOCS).
    setOwnedByMe(true);

// OK
var sharedDriveview = new google.picker.DocsView().
    setIncludeFolders(true).
    setSelectFolderEnabled(false).
    setEnableDrives(true);

googlePicker.enableFeature(google.picker.Feature.SUPPORT_DRIVES); // previously named SUPPORT_TEAM_DRIVES
//googlePicker.enableFeature(google.picker.Feature.MINE_ONLY); // NOT working properly with setEnableDrives

googlePicker.
    addView(folderView).
    addView(recentFilesView).
    addView(sharedDriveview);

googlePicker.build().setVisible(true);

推荐答案

答案:

很遗憾,这似乎无法实现.

正如您在问题中指出的,这里的问题归结为以下三点:

As you pointed out in your question, the issue here boils down to these three things:

  1. 要查看共享驱动器,需要将 DocsView.setEnableDrives()设置为 true ,并打开 Feature.SUPPORT_DRIVES .可以与 DocsView.setOwnedByMe() DocsView.setInculudeFolders()结合使用.
  2. 要查看当前用户拥有的文件,需要将 DocsView.setOwnedByMe()设置为 true Feature.MINE_ONLY >需要打开. Docsview.setOwnedByMe()可以与 DocsView.setEnableDrives()一起使用,但不能 DocsView.setIncludeFolders()一起使用>.
  3. 要在驱动器"视图中查看文件夹,需要将 DriveView.setIncludeFolders()设置为 true ,但不能与同时设置设置 DriveView.setIncludeFolders()时,将忽略DriveView.setOwnedByMe()作为 DriveView.setOwnedByMe()的值.
  1. To view Shared Drives, DocsView.setEnableDrives() needs to be set to true, and Feature.SUPPORT_DRIVES needs to be on. This can be used in conjunction with both DocsView.setOwnedByMe() and DocsView.setInculudeFolders() on their own.
  2. To view files that are owned by the current user, DocsView.setOwnedByMe() needs to be set to true, or Feature.MINE_ONLY needs to be on. Docsview.setOwnedByMe() can be used with DocsView.setEnableDrives(), but not with DocsView.setIncludeFolders().
  3. To view Folders in the Drive view, DriveView.setIncludeFolders() needs to be set to true, but can not be set at the same time as DriveView.setOwnedByMe() as the value of DriveView.setOwnedByMe() is ignored when DriveView.setIncludeFolders() is set.

可能的解决方法:

由于Picker一次只能渲染一个视图,因此您可以创建一种方法,在创建Picker并设置功能并包括以下内容之前,从用户那里获取有关访问共享驱动器还是个人驱动器的信息.自定义渲染.可以通过多种方式(例如按钮,HTML单选按钮或引导程序选项卡)来完成此操作,这些方法可以更改页面上哪个选择器可显示.

Possible workaround:

As a Picker is only able to render one view at a time, you can create a method of taking information from the user of whether to access a Shared Drive or a Personal Drive before the Picker is created and set the features and includes for the custom render. This could be done in a multitude of ways (such as a button, HTML radio button or bootstrap tab) which changes which Picker is viweable on the page.

我已代表您在Google的问题跟踪器上为此提交了功能请求.可以在此处找到此功能请求,您可以在顶部加一个星号(☆)留下来让Google知道更多人希望这个请求.

I have filed a Feature Request for this on your behalf on Google's Issue Tracker. This Feature Request can be found here, which you can give a star (☆) in the top left to let Google know more people wish for this request.

这篇关于Google云端硬盘选择器:与Feature.SUPPORT_DRIVES一起使用Feature.MINE_ONLY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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