Search

Download Google File

Last Updated: Feb 14, 2022

Articles

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

Syntax

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

Parameters

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

Returns

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

Sample

Download Google File (XYZ123, application/vnd.google-apps.document, C:\Downloads\Invoice.docx, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–, name@project-id.iam.gserviceaccount.com)

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID name@project-id.iam.gserviceaccount.com, downloads the Google file of attachment type application/vnd.google-apps.document 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/vnd.google-apps.document Google Docs
application/vnd.google-apps.drive-sdk 3rd party shortcut
application/vnd.google-apps.drawing Google Drawing
application/vnd.google-apps.file Google Drive file
application/vnd.google-apps.folder Google Drive folder
application/vnd.google-apps.form Google Forms
application/vnd.google-apps.fusiontable Google Fusion Tables
application/vnd.google-apps.map Google My Maps
application/vnd.google-apps.presentation Google Slides
application/vnd.google-apps.script Google Apps Scripts
application/vnd.google-apps.shortcut Shortcut
application/vnd.google-apps.site Google Sites
application/vnd.google-apps.spreadsheet 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?