Download Google File

Last Updated: Nov 26, 2021


Use this function to download a google file like Google Sheets or Google Docs etc., from Google Drive.


Download Google File (file_id, attachment_type, file_path, private_key, client_email)


Input Parameter Name Description
file_id ID of the Google file
attachment_type MimeType of the file
For more information, refer to the below table MIME Types
file_path Path to download the file along with the name and extension to download the file as
private_key Private key of the service account
client_email Email ID of the service account


Return Value Description
  • On Success returns 1, Path of the downloaded file
  • On Failure returns 0, Error Message


Download Google File (XYZ123, application/, C:\Downloads\Invoice.docx, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–,

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID, downloads the Google file of attachment type application/ with ID XYZ123 to the path C:\Downloads as Invoice.docx.
    Returns C:\Downloads on downloading the file.

MIME Types

MIME Type File Type
application/ Google Docs
application/ 3rd party shortcut
application/ Google Drawing
application/ Google Drive file
application/ Google Drive folder
application/ Google Forms
application/ Google Fusion Tables
application/ Google My Maps
application/ Google Slides
application/ Google Apps Scripts
application/ Shortcut
application/ Google Sites
application/ Google Sheets

This list is not exhaustive.

Ensure that Full Control permission is given to Users for the path given. To check this, right-click on the folder and choose the Security option.
Image description

To view all the Google Drive functions, click here.

Did you find what you were looking for?