internet explorer - Gdrive file get JS doesn't work in ie -
i using code retrive file google drive picker. on ie browser return error on call.
function downloadfile(file, callback) { if (file.downloadurl) { var accesstoken = gapi.auth.gettoken().access_token; var xhr = new xmlhttprequest(); xhr.open('get', file.downloadurl); xhr.setrequestheader('authorization', 'bearer ' + accesstoken); xhr.onload = function() { callback(xhr.responsetext); }; xhr.onerror = function() { callback(null); }; xhr.send(); } else { callback(null); }}
in chrome , firefox works ok, in ie 11 , + returns "access denied". error print screen
if you're using ie6 or old browsers, you'll need use specific rpc_relay file , place in same domain of application , modify creation code.
supporting older browsers
- download file: https://www.google.com/ajax/picker/resources/rpc_relay.html.
- place file somewhere in same domain application.
modify picker creation code, using corrected path:
var picker = new google.picker.pickerbuilder(). addview(google.picker.viewid.image_search). setdeveloperkey(developerkey). setcallback(pickercallback). setrelayurl('http://www.yoursite.com/somedir/rpc_relay.html'). build();
more information picker api can found in documentation
Comments
Post a Comment