使用Google选择器打开特定的MimeTypes [英] Opening specific MimeTypes with google picker
问题描述
使用现有代码,我使用这种方法创建实时文件:
使用实时API创建实时文件, / p>
createRealtimeFile =函数(标题,回调){
gapi.client.load('drive','v2',函数(){
gapi.client.drive.files.insert({$ b $'resource':{
mimeType:rtclient.REALTIME_MIMETYPE,
title:title
}
})。execute(callback);
});
}
然后我试着用这个选择器打开文件:
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);
};
尽管如果我使用setMimeTypes,没有找到任何文档。如果我删除了该过滤器,我的文档通常会显示(以及驱动器中的每次文档)。我使用的MIME类型是默认的:
rtclient.REALTIME_MIMETYPE ='application / vnd.google-apps.drive- SDK';
我正在添加appID,因为这是如何在实时操场上完成的。我也试过没有。或appID,但没有找到文档。
有关如何修复过滤器的建议?
找到在Android论坛上的答案。我必须用这个mimeType创建文件:
REALTIME_MIMETYPE ='application / vnd.google-apps.drive-sdk。'+ APPID;
并在视图中使用相同的mimeType:
view.setMimeTypes(REALTIME_MIMETYPE);
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 ?
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);
这篇关于使用Google选择器打开特定的MimeTypes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!