.
.
.
DRIVE = build('drive', 'v2', http=http)
FILES = (
('sample.csv', True),
)
for filename,convert in FILES:
metadata = {'title': filename}
res = DRIVE.files().insert(convert=convert, body=metadata, media_body=filename,fields='mimeType').execute()
print(res)
print(a)
if res:
print('Uploaded "%s" (%s)' % (filename, res['mimeType']))
Hi there,
Assuming you have provided the right Authorization Scope to access the Google Drive API, here is a method(adapted from this link) to retrieve the id of the last file you uploaded:
results = DRIVE.files().list(maxResults=1).execute()
items = results.get('items', [])
if not items:
print('No files found.')
else:
print('Files:')
for item in items:
print('{0} ({1})'.format(item['title'], item['id']))