# Developing a custom connector for Google Drive integration

**URL:** <https://community.ofelia.com/t/developing-a-custom-connector-for-google-drive-integration/12334>\
**Category:** Blog\
**Created:** [10 March 2022 10:29 UTC](https://community.ofelia.com/t/developing-a-custom-connector-for-google-drive-integration/12334 "2022-03-10T10:29:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandro.rondon\_138](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@alejandro.rondon\_138](https://community.ofelia.com/u/alejandro.rondon_138)\
**Post date:** [10 March 2022 10:29 UTC](https://community.ofelia.com/t/developing-a-custom-connector-for-google-drive-integration/12334/1 "2022-03-10T10:29:30Z")

</div>

&nbsp;

In this article, I will show you how to **create a custom connector to upload files and create folders from Bonita into Google Drive.** &nbsp;

&nbsp;

We want this connector to be **able to upload one, or multiple, documents to a Google Drive** , and we would also like to have the **option to create a new folder to upload the documents** into.

&nbsp;

Let's note here that this document upload could be done via a series of REST connectors - but we're suggested to do it via a custom connector instead. **The big advantage of doing a custom connector is that it's easier to reuse it wherever you want it to.**

Configure a custom connector with project composition feature in Bonita Studio using the wizard in the desired task of the process.

One of the benefits of&nbsp;creating a custom connector is that a **process developer can simply use the project composition in Bonita Studio, to integrate the connector and configure it easily using the wizard in the desired task of the process.**

&nbsp;

### The input for the connector configuration will be

- the DriveID in which to upload the files/create the folder

- the documents to upload

- the name of the folder if we want to create one

- the credentials required to authenticate.

&nbsp;

As output, we will have the name(s) of the file(s) uploaded, plus the link to access them.

## Use the Bonita Connector Maven Archetype

Here you can follow the [Bonita Documentation](https://documentation.bonitasoft.com/bonita/2021.2/process/connector-archetype?utm_source=community&utm_medium=social&utm_campaign=extensibility) that explains the necessary steps:

- Generate the project using the archetype

- Leave the connector implementation as it is, since it already has all the required information

- Define the connector as indicated in the documentation, with the following data:

&nbsp;

&nbsp;

## Develop the business logic

Now, add the business logic of the connector in the project.

&nbsp;

Create a library to include the main functions (connect to drive, create folder, upload files, read folder and delete folder) using the [Google Drive v3 API](https://developers.google.com/drive/api/v3/folder).&nbsp; This library, gDriveUtils, will be in the same project as the connector.

&nbsp;

Next step is to retrieve and validate all input parameters. You can use the proposed scripts to validate that the mandatory inputs are the correct type and are not empty.

 ![](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/1X/fefbe8af4647c03a5a0e622a700723fc6d7cdd2d.png)

Another important step will be to add a function to retrieve the case documents in Bonita. For this, use the [Bonita Engine API](https://documentation.bonitasoft.com/bonita/2021.2/api/engine-api-overview?utm_source=community&utm_medium=social&utm_campaign=extensibility).

&nbsp;

 ![](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/1X/60c5c7b840597e615b29d6b0d3acc0dd95ca5f01.png)

&nbsp;

And then add the complete business logic using our inputs, validations and functions.

&nbsp;

 ![](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/1X/765af0c71fc1abacacb51cd525a57236959d0690.png)

## Add Unit Tests

Add unit tests here. For this, you can use the [Mockito framework](https://site.mockito.org/)to create the dummy elements that are needed (Bonita Process API, Documents to upload, etc.)

&nbsp;

We also suggest adding a cleanup section to delete all files and folders created for the test.

## Publish in a public repository

Use Github Actions to publish this extension in a private Maven repository, so it will be accessible to be uploaded in Bonita Studio.

&nbsp;

Of course other automatization means can be used as well (Jenkins, Bamboo, etc),&nbsp; or this extension can be published and distributed manually.

## Source code of the developed custom connector

The source code of the connector we developed for this demo can be found in the Bonita Community Projects section [here](http://community.ofelia.com/project/gdrive-custom-connector?utm_source=community&utm_medium=social&utm_campaign=extensibility).

&nbsp;
