google.picker.DocsUploadView()。setParent(' XXXX')问题

时间:2017-11-03 17:42:21

标签: google-api

尝试获取此代码块的帮助。 我的脚本首先查找特定文件夹,如果存在,则将文件夹的id传递给google.picker.DocsUploadView()。当我将setParent的值硬编码为' gdfid'时,一切都运行良好。另一方面,我需要参数化代码。

提前感谢您的任何帮助

皮特

这是我的代码:

  var gdfid;

  function createPicker() {
    if (pickerApiLoaded && oauthToken) {
    gapi.client.drive.files.list({
        "corpora": "user",
        "spaces": "drive",
        "fields": "files(id,name)",
        "q": "name = 'myUploads"
      }).then(function(response) {
             console.log( response.result.files.length );
            if (response.result.files.length > 0) {
                console.log( response.result );
                gdfid = response.result.files[0].id;
            }
        //alert('Folder ID: ' + gdfid);
      });
      var picker = new google.picker.PickerBuilder().
      setTitle('Upload to myPratt Folder').
      enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
      enableFeature(google.picker.Feature.NAV_HIDDEN).
      addView(new google.picker.DocsUploadView().
          setIncludeFolders(false).
          setParent('gdfid')). //tried with and without quotes
          setOAuthToken(oauthToken).
          setDeveloperKey(developerKey).
          setCallback(pickerCallback).
          build();
      picker.setVisible(true);
    }
  }

0 个答案:

没有答案