Cloud

google_drive_download

Downloads files from Google Drive.

Can download a file from Google Drive based on a file ID.

Authentication

By default, this connector will use Google Application Default Credentials (ADC) to authenticate with Google APIs.

To use this mechanism locally, run these gcloud commands:

# Log in for the application default credentials and add scopes for read-only Drive access
gcloud auth application-default login --scopes='openid,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/drive.readonly'
# When logging in with a user account, you may need to set the quota project for the application default credentials
gcloud auth application-default set-quota-project <project-id>

Replace <project-id> with your Google Cloud project ID.

Otherwise if using a service account, you can create a JSON key for the service account and set it in the credentials_json field. In order for a service account to access files in Google Drive either files need to be explicitly shared with the service account email, otherwise domain wide delegation can be used to share all files within a Google Workspace.

Try out the example pipeline on this page, which downloads all files from your Google Drive.

  • Common

  • Advanced

processor:
  label: ""
  google_drive_download:
    credentials_json: "" # No default (optional)
    file_id: "" # No default (required)
    mime_type: "" # No default (required)
    shared_drives: false
processor:
  label: ""
  google_drive_download:
    credentials_json: "" # No default (optional)
    file_id: "" # No default (required)
    mime_type: "" # No default (required)
    export_mime_types:
      application/vnd.google-apps.document: "text/markdown"
      application/vnd.google-apps.drawing: "image/png"
      application/vnd.google-apps.presentation: "application/pdf"
      application/vnd.google-apps.script: "application/vnd.google-apps.script+json"
      application/vnd.google-apps.spreadsheet: "text/csv"
    shared_drives: false

Fields

credentials_json

The JSON key for your service account (optional). If left empty, Application Default Credentials are used.

This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see Manage Secrets before adding it to your configuration.

Type: string

export_mime_types

Maps Google Drive MIME types to supported file export formats. The MIME type is the key, and the export format is the value.

Type: object<string>

Default:

application/vnd.google-apps.document: "text/markdown"
application/vnd.google-apps.drawing: "image/png"
application/vnd.google-apps.presentation: "application/pdf"
application/vnd.google-apps.script: "application/vnd.google-apps.script+json"
application/vnd.google-apps.spreadsheet: "text/csv"
# Examples:
export_mime_types:
  application/vnd.google-apps.document: application/pdf
  application/vnd.google-apps.drawing: application/pdf
  application/vnd.google-apps.presentation: application/pdf
  application/vnd.google-apps.spreadsheet: application/pdf

# ---

export_mime_types:
  application/vnd.google-apps.document: application/vnd.openxmlformats-officedocument.wordprocessingml.document
  application/vnd.google-apps.drawing: image/svg+xml
  application/vnd.google-apps.presentation: application/vnd.openxmlformats-officedocument.presentationml.presentation
  application/vnd.google-apps.spreadsheet: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

file_id

The ID of the file to download from Google Drive.

This field supports interpolation functions.

Type: string

mime_type

The MIME type of the file for download.

This field supports interpolation functions.

Type: string

shared_drives

Whether or not to include shared drives.

Type: bool

Default: false

Examples

Download files from Google Drive

This examples downloads all the files from Google Drive

pipeline:
  processors:
    - google_drive_search:
        query: "name = 'Test Doc'"
    - google_drive_download:
        file_id: "${!this.id}"
        mime_type: "${!this.mimeType}"