How to download files from Google Drive using SSIS

Introduction

In today’s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you’re a user of SQL Server Integration Services (SSIS) and looking to integrate Google Drive into your data workflow, you’re in luck. ZappySys SSIS PowerPack offers a powerful Google Drive Connector that makes downloading files from Google Drive a breeze. In this guide, we’ll walk you through the process of downloading files from Google Drive using SSIS and the ZappySys SSIS PowerPack Google Drive Connector.

Prerequisites

Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
  1. SSIS designer installed. Sometimes it is referred to as BIDS or SSDT (download it from the Microsoft site).
  2. Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
  3. Make sure ZappySys SSIS PowerPack is installed (download it, if you haven't already).
  4. (Optional step). Read this article, if you are planning to deploy packages to a server and schedule their execution later.

Download files from Google Drive with SSIS:

In this section, we will learn how to configure and use Google Drive Connector in the API Source & API Destination to download files from Google Drive.

  1. Begin with opening Visual Studio and Creating a New Project.
  2. Select Integration Service Project and in the new project window set the appropriate name and location for the project. Click OK.
  3. In the new SSIS project screen you will find the following:
    1. SSIS ToolBox on the left sidebar
    2. Solution Explorer and Property Window on the right bar
    3. Control flow, data flow, event Handlers, Package Explorer in tab windows
    4. Connection Manager Window at the bottom

    -`zappysys ssis project with toolbox

    NOTE: If you don’t see ZappySys SSIS PowerPack Task or Components in the SSIS Toolbox, please refer to this help link.
  4. Now, Drag and Drop the SSIS Data Flow Task from the SSIS Toolbox. Double-click on the Data Flow Task to see the Data Flow Designer.
  5. From the SSIS toolbox drag and drop API Source (Predefined Templates) on the data flow designer surface, and double-click on it to edit it:
  6. Select New Connection to create a new connection:

Configuring the Google Drive Connector

  1. Use a preinstalled Google Drive Connector from the Popular Connector List or press the Search Online radio button to download Google Drive Connector. Once downloaded simply use it in the configuration:
    ssis googledrive template selection walkthrough
  2. Proceed with selecting the desired Authentication Type. Then select API Base URL (in most cases default one is the right one). Finally, fill in all the required parameters and set optional parameters if needed.
  3. After configuring all the required properties in the API Connection Manager, please click on the “Test Connection” button to confirm that the connection is established successfully.

    Method1: Connect to Google Drive using User Account [OAuth]

    You may press a link Steps to Configure which will help set certain parameters.

    SSIS API Source - Generate Token - Google Drive with User Account

    SSIS API Source – Generate Token – Google Drive with User Account

    Method2: Connect to Google Drive using Service Account [OAuth]

    You may press a link Steps to Configure which will help set certain parameters.

    SSIS API Source - Generate Token - Google Drive with Service Account

    SSIS API Source – Generate Token – Google Drive with Service Account

How to download a single file from Google Drive

In the API Source Component, we’ve chosen the API Connection Manager. Next, we need to configure the remaining properties of the component to download the single file from Google Drive.

  1. Choose the Download a file endpoint from the “Select Table/Endpoint” dropdown menu.
  2. To access detailed API documentation for downloading files, you can click on the following link: Help for: Download a File.
  3. Please choose a File ID from the drop-down menu to indicate which file you wish to download. This is an essential parameter for the download process.
  4. Please indicate the desired filename for the file being downloaded by setting the FileName parameter.
  5. If you intend to replace the local file with the one being downloaded, please select the ‘AlwaysOverwrite‘ option from the dropdown menu labeled ‘FileOverwriteMode‘. Alternatively, you can choose ‘FileIfExists’ or ‘SkipIfExists’ based on your specific needs.

Please refer to the sample screenshot below.

SSIS API Source - Google Drive - Download Single File

SSIS API Source – Google Drive – Download Single File

Once you have configured all the mentioned properties above, please click on the “Preview Data” button to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the ZappySys Google Drive Connector for downloading a Single file from Google Drive.

How to download multiple files from Google Drive

In the API Destination Component, we have chosen the API Connection Manager. Now, we must proceed to configure the remaining properties of the component to facilitate the download of multiple files from Google Drive. Additionally, we should make use of an OLE DB Source and Derived Column component to map the files for the download process.

  1. Drag and drop the OLE DB Source Component from the SSIS Toolbox. Double-click on the OLE DB Source Component to initiate its configuration.
    OLE DB Source - Drag and Drop

    OLE DB Source – Drag and Drop

  2. Create a new OLE DB Connection Manager and configure your SQL Server settings for the connection. Next, select the Data access mode, specify the name of the table or view, or write an SQL Command. Afterward, click on the ‘Preview’ button to view a preview and check the ‘Columns’ tab for the source columns.
    SSIS OLE DB Source - Configure SQL Connection and fetch the table data

    SSIS OLE DB Source – Configure SQL Connection and fetch the table data

  3. Next, drag and drop the Derived Column Component from the SSIS Toolbox. Double-click on the Derived Column Component to begin its configuration.
    Drag and drop the Derived Column

    Drag and drop the Derived Column

  4. Now, add a new Derived Column by setting the expression to concatenate FilePath and FileName. Click ‘OK’ to save the configuration.
    SSIS Derived Column - Add New Column & Set Expression

    SSIS Derived Column – Add New Column & Set Expression

  5. Now, drag and drop the API Destination Component from the SSIS Toolbox. Double-click on the API Destination Component to begin its configuration.
    Drag and Drop the SSIS API Destination Component

    Drag and Drop the SSIS API Destination Component

  6. Double-click on the API Destination component to configure it for uploading multiple files to Google Drive.
    1. Choose the Download a file endpoint from the “Select Table/Endpoint” dropdown menu.
    2. To access detailed API documentation for downloading files, you can click on the following link: Help for: Download File.
    3. Please specify the ‘FileOverwriteMode’ option as ‘AlwaysOverwrite,’ or you can choose ‘FailIfExists’ or ‘SkipIfExists’ options based on your requirements.
      Please refer to the sample screenshot below.
      SSIS API Destination Component - Configure Settings Tab

      SSIS API Destination Component – Configure Settings Tab

    4. Now, go to the Mappings tab and specify the source columns with the corresponding target properties.
      Note: Here We’re mapping FileID with $$Id and FileNameWithPath with $$ResponseDataFile. You can create mappings based on your Source columns
      Please refer to the sample screenshot below
      SSIS API Destination Component - Configure Mappings Tab

      SSIS API Destination Component – Configure Mappings Tab

  7. Once you have configured all the mentioned properties above, please click on the “Preview Data” button from the Settings tab to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the ZappySys Google Drive Connector for downloading multiple files from Google Drive.
    Please refer to the sample screenshot below.
    Download Multiple files from Google Drive

    Download Multiple files from Google Drive

Conclusion

In this blog, we learned how to connect with Google Drive using SSIS API Connection Manager and download single or multiple files from Google Drive using a combination of SSIS components, including the SSIS API Source component, SSIS API Destination component, OLE DB Source component, and Derived Column component.

Posted in Google API, SSIS API Source, SSIS Components, SSIS PowerPack and tagged , , , , , , .