I try to download Google Drive documents (with a Drive app) with this python function. it jumps every time to the # The file doesn't have any content stored on Drive
part.
def download_file(service, drive_file):
"""Download a file's content.
Args:
service: Drive API service instance.
drive_file: Drive File instance.
Returns:
File's content if successful, None otherwise.
"""
download_url = drive_file.get('downloadUrl')
if download_url:
resp, content = service._http.request(download_url)
if resp.status == 200:
print 'Status: %s' % resp
return content
else:
print 'An error occurred: %s' % resp
return None
else:
# The file doesn't have any content stored on Drive.
return None
However I never get the HTML-content of a GDrive document. Is something wrong with my mime settings (HTML Mime type) or should I use another API function?
You need to export the Google Doc, not download it. Check the Google Drive documentation for exporting files, you will need to replace your URL with something like:
download_url = file['exportLinks']['text/html']