从Google Drive请求文件元数据时缺少'downloadUrl'参数
我试图从javascript应用程序中获取电子表格文档的内容。但是'/drive/v2/files/' + documentId
的响应没有“downloadUrl”属性。从Google Drive请求文件元数据时缺少'downloadUrl'参数
我的代码是:
var apiKey, clientId, documentId, scopes; documentId = "XXXXXXXXXX";
clientId = 'XXXXXXXXXXXXX.apps.googleusercontent.com';
apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXX';
scopes = 'https://www.googleapis.com/auth/drive';
window.OnLoadCallback = function() {
console.log("google client loaded!");
gapi.client.setApiKey(apiKey);
return window.setTimeout(checkAuth, 1);
};
window.checkAuth = function() {
return gapi.auth.authorize({
client_id: clientId,
scope: scopes,
immediate: true
}, function(e) {
console.log("authorized!");
return gapi.client.request({
'path': '/drive/v2/files/' + documentId,
'method': 'GET',
callback: function(theResponseJS, theResponseTXT) {
var downloadUrl, myToken, myXHR;
console.log(theResponseJS);
console.log(theResponseJS.downloadUrl); //is missing
myToken = gapi.auth.getToken();
myXHR = new XMLHttpRequest();
myXHR.open('GET', theResponseJS.downloadUrl, true);
myXHR.setRequestHeader('Authorization', 'Bearer ' + myToken.access_token);
myXHR.onreadystatechange = function(theProgressEvent) {
if (myXHR.readyState === 4) {
if (myXHR.status === 200) {
return console.log(myXHR.response);
}
}
};
return myXHR.send();
}
});
});
};
我在做什么错?
谢谢!
回答:
Google doc文件有一些内部/专有格式,似乎无法直接访问。唯一的选择是通过“exportLinks”集合将Google文档转换为其他定义良好的文档类型。
以上是 从Google Drive请求文件元数据时缺少'downloadUrl'参数 的全部内容, 来源链接: utcz.com/qa/263742.html