I have the shared link of a Google Drive folder. I want to download the entire folder using the drive API. The way I am doing this currently is that I get a list of 'children' and then download all the 'children' instances into the folder. The problem is that for each 'children' instance download, a request is sent to googleapis. So, if there are a 1000 files, 1000 requests are sent. I have a folder with more than 10M small files and Google limits the number of requests to 10M per day. I wanted to know if there is some way(any function in drive api) to download the entire folder at once? Here is my code:
storage = Storage(CredentialsModel, 'id', task_request.user, 'credential')
credential = storage.get()
http = httplib2.Http()
http = credential.authorize(http)
service = build('drive', 'v2', http=http)
file_list = []
children = service.children().list(folderId=folder_id, q=q, **param).execute()
for child in children.get('items', []):
file_list.append(child['id'])
for k in range(len(file_list)):
curr_file = service.files().get(fileId=file_list[k]).execute()
download_url = curr_file.get('downloadUrl')
if download_url:
resp, content = service._http.request(download_url)
if resp.status == 200:
title = drive_file.get('title')
path = title
file = open(path, 'wb')
file.write(content)