Javascript 谷歌硬盘文件元数据读取
我正在尝试使用google Picker在我的Web应用程序上显示google drive选定的图像。为了获得图像的网络内容,我需要读取元数据。然而,我得到了一个类似这样的错误Javascript 谷歌硬盘文件元数据读取,javascript,google-chrome-extension,google-drive-api,Javascript,Google Chrome Extension,Google Drive Api,我正在尝试使用google Picker在我的Web应用程序上显示google drive选定的图像。为了获得图像的网络内容,我需要读取元数据。然而,我得到了一个类似这样的错误 Uncaught TypeError: Cannot read property 'files' of undefined localhost:169 printFile localhost:169 pickerCallback localhost:156 K.Ld default.I.js:103 _.zc cb=ga
Uncaught TypeError: Cannot read property 'files' of undefined localhost:169
printFile localhost:169
pickerCallback localhost:156
K.Ld default.I.js:103
_.zc cb=gapi.loaded_0:57
_.Ib
这是我正在使用的代码
function printFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
});
}
一旦我得到了图像的元数据,我将使用Webcontent在webapp上显示图像,但它只是没有得到元数据。请告诉我如何修复此错误 使用另一段代码使其工作:
function printFile(fileId) {
var theID = fileId;
var request = gapi.client.request({
'path': '/drive/v2/files/'+theID,
'method': 'GET',
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
console.log('WebContent: ' + resp.webContentLink);
});
}
使用另一段代码使其正常工作:
function printFile(fileId) {
var theID = fileId;
var request = gapi.client.request({
'path': '/drive/v2/files/'+theID,
'method': 'GET',
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
console.log('WebContent: ' + resp.webContentLink);
});
}