Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 425
Giannis Avatar asked Nov 19 '25 18:11

Giannis


2 Answers

You should look for mimeType you created with. You created your file with mimeType rtclient.REALTIME_MIMETYPE and you're looking for files with mimeType rtclient.REALTIME_MIMETYPE+ "."+realTimeOptions.appId That is the reason why you're not getting any files.

Change filepicker code to:

view.setMimeTypes(rtclient.REALTIME_MIMETYPE);

And make sure you change

rtclient.REALTIME_MIMETYPE = 'application/{{YOURE_CUSTOM_MIMETYPE}}';

to avoid collision with other apps.

like image 200
JunYoung Gwak Avatar answered Nov 22 '25 04:11

JunYoung Gwak


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);
like image 32
Giannis Avatar answered Nov 22 '25 02:11

Giannis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!