So after crawling a bit on the internet I found a workaround :
It's impossible to retreive a file from Gdrive with a task name or a filename are they are all identify with their unique ID.
Solution is to create a function that crawls into your files in your drive and select thoses corresponding to your task. in my case it look like :
import ee
class gdrive(object):
def __init__(self):
self.initialize = ee.Initialize()
self.credentials = ee.Credentials()
self.service = discovery.build(serviceName='drive', version='v3', cache_discovery=False, credentials=self.credentials)
def get_files(self, file_name):
""" look for the file_name patern in my Gdrive files and retreive a list of Ids"""
items = self.get_items()
files = []
for item in items:
if (file_name in item['name']):
files.append({'id':item['id'], 'name': item['name']})
return files
then in the same gdrive
object I created a function that retreive all my selected files from my drive to my local path.
from googleapiclient.http import MediaIoBaseDownload
class gdrive(object):
# [...] som code
def download_files(self, files, local_path):
service = self.service
for fId in files:
request = service.files().get_media(fileId=fId['id'])
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
#print('Download %d%%.' % int(status.progress() * 100))
fo = open(local_path+fId['name'], 'wb')
fo.write(fh.getvalue())
fo.close()
hope that it will help someone
service
come from? I think your question is related to GDrive Python API and not GEE