2016-10-29 5 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

"[...]은 무엇을 의미합니까?하지만 'id'가 아니어야합니다." 그것은 뭘해서는 안되나요? –

답변

2

편집 안 : 다음은 메타 데이터에 액세스하고 얻을 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. = 표지판,
  2. PyDrive은 구글 드라이브 API v2가 사용을 둘러싼 자신의 공간을 소개하는, 그래서 당신은 대신 the v2 search parameter page를 사용할 수 있는지 확인하지 마십시오
  3. 입니다

    확인 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 문서를 확인하십시오.