2013-01-20 38 views
1

我想要使用谷歌選取器獲取谷歌驅動器選定的圖像顯示在我的webapp上。爲了獲得圖像的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); 
     }); 
    } 

代碼一旦我得到的圖像,我會使用網絡內容的圖像顯示在Web應用程序中的元數據,但它只是沒有獲得元數據。請告訴我如何解決這個錯誤。

回答

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

謝謝!任何想法爲什麼官方的示例代碼不起作用? –

相關問題