2016-10-29 4 views
0

この機能:無効なクエリ、ドライブのAPI、ずつfiles.list()

drive.ListFile({'q': " id = '"+Value+"' and trashed=false"}).GetList() 

リターン: "無効なクエリ" の問題は、セレクタ 'ID' にある

、私はこの条件Iを上げる場合、私はこのドキュメントを使用していますパラメータ 'ID'

https://developers.google.com/drive/v2/reference/files/listhttps://developers.google.com/drive/v3/web/search-parameters

を辞書を返します

これは、他のセレクタのために完璧に動作しますが、「ID」のために

+0

質問がありますか?または目的? – Ukimiku

+0

私は関数を実行する必要があります – simone989

+0

"[...]とは何を意味しますか?それは何であってはなりませんか? –

答えて

2

EDITすべきではない。ここでは、メタデータにアクセスし、取得し、そのIDによって、既存のファイルの内容を設定することができる方法です。

# Calling CreateFile() with an existing ID links it to the already existing file. 
gdrive_file = drive.CreateFile({'id': '<your file id>'}) 
gdrive_file.FetchMetadata() # Only needed if you want to view or edit its metadata. 
# Do things with metadata here as needed. 

gdrive_file.GetContentFile('dog.png') # Download content file. 

# And/or upload a new content file. 
gdrive_file.SetContentFile('cat.png') 
gdrive_file.Upload() 

もちろん、docsには多数の例があります。

オリジナル: 例についてはdocs for file listingsをご覧ください。

あなたはIDがある

  1. =兆候を囲む独自のスペースを導入しないでくださいPyDriveは、GoogleドライブのAPI V2を使用していますので、あなたの代わりにthe v2 search parameter pageを使用していることを確認、
  2. ていることを確認してくださいGoogleドライブで割り当てられたフォルダID、this SO questionにはIDの検索方法が記載されています。たとえば、

from pydrive.drive import GoogleDrive 

drive = GoogleDrive(gauth) # Create GoogleDrive instance with authenticated GoogleAuth instance 
folder_id = "insert your folder ID here" 

# Auto-iterate through all files in the specified folder. 
file_list = drive.ListFile({ 
    'q': "{id} in parents and trashed=false".format(id=folder_id) 
}).GetList() 

for file1 in file_list: 
    print('title: %s, id: %s' % (file1['title'], file1['id'])) 
1

idは、ファイル検索を実行するためにサポートされるクエリフィールドではありません。

for Drive API v2のドキュメントを参照して、検索する有効なフィールドを確認してください。

関連する問題