Google Drive文件读取元数据

use*_*649 1 javascript google-chrome-extension google-drive-api

我正在尝试使用Google Picker在我的webapp上显示谷歌驱动器所选图像.为了获得图像的webcontent,我需要阅读元数据.但是我收到的错误是这样的

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
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的代码

    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);
      });
     }
Run Code Online (Sandbox Code Playgroud)

一旦我获得图像的元数据,我将使用Webcontent在webapp上显示图像,但它只是没有获取元数据.请告诉我如何解决此错误.

use*_*649 5

使用另一段代码工作了:

    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);
             });
    }
Run Code Online (Sandbox Code Playgroud)