谷歌驱动器文件元数据读取

Google Drive files meta data read

本文关键字:读取 元数据 文件 驱动器 谷歌      更新时间:2023-09-26

我试图让谷歌驱动器选定的图像显示在我的web应用程序使用谷歌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上显示图像,但它只是没有得到元数据。请告诉我如何解决这个错误。

使用另一段代码使其工作,即:

    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);
             });
    }