1

これは機能します:

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

return: 「無効なクエリ」

問題はセレクター「id」にあります。この条件を上げると、パラメーター「id」を持つ辞書が返されます

私はこのドキュメント、 https://developers.google.com/drive/v2/reference/files/list および https://developers.google.com/drive/v3/web/search-parametersを使用しています

他のセレクターでは完全に機能しますが、「id」はそうすべきではありません

4

2 に答える 2

4

編集:これは、メタデータにアクセスし、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()

そしてもちろん、ドキュメントにはたくさんの例があります。

オリジナル:例については、ファイル リストのドキュメントを参照してください。

あなたが

  1. =看板の周りに自分の空間を紹介するのではなく、
  2. PyDrive は Google Drive API v2 を使用するため、代わりにv2 検索パラメーター ページを使用してください。
  3. ID は、Google ドライブによって割り当てられたフォルダー ID です。この SO の質問には、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']))
于 2016-10-30T08:47:43.043 に答える
1

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

Drive API v2のドキュメントをチェックして、検索に使用できる有効なフィールドを確認してください。

于 2016-10-30T19:07:28.063 に答える