Search code examples
google-drive-apigoogle-drive-realtime-apigoogle-picker

Opening specific MimeTypes with google picker


I am working with realtime API and I am making use of realtime-client-utils.

Using existing code, I am creating realtime files with this method:

createRealtimeFile = function(title, callback) {
  gapi.client.load('drive', 'v2', function() {
    gapi.client.drive.files.insert({
      'resource': {
        mimeType: rtclient.REALTIME_MIMETYPE,
        title: title
      }
    }).execute(callback);
  });
}

and then I am trying to open files with this picker:

var popupOpen = function () {
      var token = gapi.auth.getToken().access_token;
      var view = new google.picker.View(google.picker.ViewId.DOCS);
      view.setMimeTypes(rtclient.REALTIME_MIMETYPE+ "."+realTimeOptions.appId);
      var picker = new google.picker.PickerBuilder()
          .enableFeature(google.picker.Feature.NAV_HIDDEN)
          .setAppId(realTimeOptions.appId)
          .setOAuthToken(token)
          .addView(view)
          .addView(new google.picker.DocsUploadView())
          .setCallback(pickerCallback)
          .build();
      picker.setVisible(true);
    };

Although if I use the setMimeTypes, no documents are found. If I remove that filter, my documents appear normally(along with every time of document in the drive). THe mime type I am using is the default one:

rtclient.REALTIME_MIMETYPE = 'application/vnd.google-apps.drive-sdk';

I am adding the appID as this is how its done on realtime-playground. I also tried without the "." or the appID but no documents are found.

Any suggestions about how to fix the filter ?


Solution

  • Found the answer on an android forum. I had to create files with this mimeType:

    REALTIME_MIMETYPE = 'application/vnd.google-apps.drive-sdk.'+appID;
    

    and use same mimeType on view :

      view.setMimeTypes(REALTIME_MIMETYPE);