async function downloadFile(drive, fileId, destPath, exportMimeType = null) try let response; if (exportMimeType) response = await drive.files.export( fileId, mimeType: exportMimeType , responseType: 'stream' ); else response = await drive.files.get( fileId, alt: 'media' , responseType: 'stream' );

args = parser.parse_args()

def download(service, file_id, output_path=None, export_mime=None): """ Download a file from Google Drive.

| Google Workspace Type | Source MIME | Export to | Target MIME | |-----------------------|-------------|-----------|--------------| | Document | application/vnd.google-apps.document | PDF | application/pdf | | Document | | DOCX | application/vnd.openxmlformats-officedocument.wordprocessingml.document | | Document | | TXT | text/plain | | Spreadsheet | application/vnd.google-apps.spreadsheet | XLSX | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | | Spreadsheet | | CSV | text/csv | | Spreadsheet | | PDF | application/pdf | | Presentation | application/vnd.google-apps.presentation | PPTX | application/vnd.openxmlformats-officedocument.presentationml.presentation | | Presentation | | PDF | application/pdf | Python Example First, install the library: