我正在创建一个应用程序,我需要提供Drive Picker小部件,以便用户可以上传一些文件。现在我想限制用户,以便他们只能从“团队驱动器”中选择文件,而不是从其他任何地方选择。
我尝试在onPickerInit
事件中添加方法。
这是我在onPickerInit
事件中调用的函数,
function fetchFolder(widget, pickerBuilder) {
pickerBuilder.addView(new google.picker.DocsView()
.setParent('TeamDriveId')
.setIncludeFolders(true));
}
此方法限制用户仅选择特定的团队驱动器,但我的问题是如何提供动态选项,以便用户可以从他们的任何团队驱动器中进行选择,而不仅限于一个团队驱动器。此外,他们也无法从自己的Google云端硬盘中进行选择。
答案 0 :(得分:3)
似乎这种情况需要低级别的驱动器选择器调整,所以让我们开始删除App Maker开箱即用的所有设置:
onPickerInit
事件// Enable Team Drives
pickerBuilder.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES);
// Let users to select files from any Team Drive
var multiTeamDrive = new google.picker.DocsView();
multiTeamDrive.setIncludeFolders(true)
.setEnableTeamDrives(true);
pickerBuilder.addView(multiTeamDrive);
// This feature need to be set to force `setParent` work.
// Seems to be Drive Picker's bug
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
// Force users to upload files to a specific Team Drive
var uploadView = new google.picker.DocsUploadView();
uploadView.setParent('Fancy KEY from Team Drive folder URL')
.setLabel('Upload to Team Drive XXX');
pickerBuilder.addView(uploadView);
备注强>