【问题标题】:How do I limit the Google Drive Picker UI to displaying just Google Documents?如何将 Google Drive Picker UI 限制为仅显示 Google Documents?
【发布时间】:2014-01-27 06:27:29
【问题描述】:

reference guide 建议我可以使用addView() 函数来指定包含哪些 Google Drive 项目。这很好,但尽管这是仅适用于 Google 文档的推荐视图 - google.picker.​ViewId.DOCUMENTS 似乎还包括任何上传到驱动器并且是文档的文件,例如MS Word 格式、Open Office 格式、纯文本和富文本格式。

有什么方法可以限制 Picker 只为用户提供 Google 文档?

为了清楚起见,这是我实例化 Picker 的代码。

this.picker = new google.picker.PickerBuilder().
            addView(google.picker.ViewId.DOCUMENTS).
            setAppId(this.clientId).
            setOAuthToken(accessToken).
            setCallback(this._pickerCallback.bind(this)).
            build().
            setVisible(true);

【问题讨论】:

    标签: google-drive-api google-picker


    【解决方案1】:

    因此,Google 将 Drive 与 Docs 相结合的品牌重塑导致了一些不一致的命名。 Google Drive Documents 实际上是指存储在 Google Drive 中的任何 Document,包括但不限于问题中列出的那些文件类型。

    要解决这个问题,您可以创建一个视图而不是使用现有视图,并指定您有兴趣列出的 MIME 类型。

    这是其他人发现自己卡住的代码。

    var view = new google.picker.DocsView(google.picker.ViewId.DOCUMENTS)
        .setMimeTypes("application/vnd.google-apps.document");
    
    this.picker = new google.picker.PickerBuilder().
                addView(view).
                setAppId(this.clientId).
                setOAuthToken(accessToken).
                setCallback(this._pickerCallback.bind(this)).
                build().
                setVisible(true);
    

    感谢 G+ 上 Google 云端硬盘开发者社区的一位用户

    Original Post in the G+ Community

    【讨论】:

    • 谢谢!对于其他 mime 类型:developers.google.com/drive/api/v3/mime-types。要显示多种类型(例如 Documents 和 Presentations),您需要在 setMimeTypes() 的单个字符串参数中提供一个逗号分隔的 mime 类型列表
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    相关资源
    最近更新 更多