Get file size from Google Drive Api (python)

Viewed 6286

I'm trying to figure out how to retrieve the file size of a file uploaded to Google Drive. According to the docs this should be in the file metadata... but when I request it, file size is not in the metadata at all.

file = self.drive_service.files().get(fileId=file_id).execute()
print(file)

>>> {u'mimeType': u'application/x-zip', u'kind': u'drive#file', u'id': u'0B3JGbAfem1CrWnhtWq5qYlkzSXf', u'name': u'myfile.ipa'}

What am I missing here? How can I check the file size?

3 Answers

Passing 'size' within fields should work.

Example: fields='size'

Although if the file is native to Google Drive such as a file made within Google Docs or Sheets those files do not take up space against your quota and thus don't have a size.

Related