2014-11-06 131 views
1

列出了所有的文件,我可以知道我可以列出使用GoogleAPIS庫節點:谷歌雲端硬盤API使用查詢

https://github.com/google/google-api-nodejs-client/

我不知道,如何在谷歌驅動器使用的查詢中的所有文件使用這個庫!

我不知道我應該在哪裏把我的詢問,我曾嘗試下面的代碼,但我沒有得到任何迴應..

測試1:

drive.files.list("mimeType='image/jpg'", function(data){ 
    //I am getting all the data, the query is not working.. 
)); 

測試2:

drive.files.list({ 
    media: { 
     mimeType: 'application/vnd.google-apps.folder' 
    } 
}, function(err, data){ 
    //I am getting all the data, the query is not working.. 
}); 

測試3:

drive.files.list({ 
    resource: { 
     mimeType: 'application/vnd.google-apps.folder' 
    } 
}, function(err, data){ 
    //This returns error not working at all! 
}); 
+0

您是否嘗試過在看什麼? https://developers.google.com/drive/v2/reference/files/list – DaImTo 2014-11-06 14:03:37

+2

@DaImTo當然,我已經閱讀過它們,但是提供的Javascript樣本沒有使用GoogleAPIs節點庫... – Tim 2014-11-06 14:06:54

回答

1

您可以查看這裏給出的drive.files.list函數https://github.com/google/google-api-nodejs-client/blob/master/apis/drive/v2.js#L733,併爲它使用類似下面的內容。對列表功能的輸入參數

var drive = google.drive({ version: 'v2', auth: oauth2Client }); 
drive.files.list({ 
    q='mimeType='image/jpg'' 
}, callback); 

更多細節上https://developers.google.com/drive/v2/reference/files/list

+0

喲也試過!但不工作!我已編輯我的questiosn – Tim 2014-11-06 14:50:23

+0

我可以得到圖像文件,但我有問題,當我嘗試搜索文件夾,我沒有得到任何數據.. q:「mimeType ='application/vnd.google-apps.folder'」,我有空陣... – Tim 2014-11-06 15:21:23

+0

首先檢查你的範圍。您正在尋找的文件夾可能超出了授權範圍,例如。如果你有drive.file範圍,但該文件夾不是由你的應用程序創建的。接下來檢查響應中的nextPageToken。可以接收一個空數組,並與nextPageToken一起告訴你有更多的結果。最後,直接考慮對REST API進行編碼總是值得的。該庫在Alpha中,因此可能不是最穩定/可靠的訪問機制。 – pinoyyid 2014-11-07 11:34:25

相關問題