1

我正在尝试使用 Google Picker 在我的 web 应用程序上显示谷歌驱动器选择的图像。为了获取图像的网络内容,我需要读取元数据。但是我收到一个类似这样的错误

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 上显示图像,但它只是没有获得元数据。请告诉我如何解决此错误。

4

1 回答 1

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);
             });
    }
于 2013-01-21T00:53:22.013 回答