Configuring connectors - Google Cloud Storage

Google Cloud Storage is a highly reliable and secure data storage for organizations of all sizes. Studio provides you with the Google Cloud Storage connector that enables you to easily build apps while using the capabilities of the Cloud Storage to optimize response times, customize data storage, build disaster recovery plans, and so on.

Configuring Google Cloud Storage connector

To add a Google Cloud Storage connector, under Studio > Connectors, click (+) Connector and under APIs, select the Google Cloud Storage connector.

  • Add a Google Cloud Storage Account to Authenticate. Here you can add an account by using Connect Google Cloud Storage.

  • For this you need to first configure the account by adding the account name under Tag your Account with relevant name and the Service Account JSON.
    The Service Account JSON should be copied from the Google Cloud Storage > APIs and Services > Credentials.

    Create a Service Account as that is all that you need for your Connector. You can refer to this article here to know how to get started by creating a Service account.

  • Enter all the details as required to create the Service account.

  • It will be available under Service accounts.

  • From the Service Account, you need to create a Key after you have added the details and given the necessary permissions. Create a JSON Key type and download the file. Keep it handy for use for connector configuration.

  • From the file created copy the Key and paste it in the Service Account JSON.

  • Your connector account configuration is now done.

  • If you have already configured your account, you simply need to choose it from the list. In case you want to make any changes to the account configuration you can hover your mouse across the account and you can note the edit and delete options. Click to Edit.

Using Google Cloud Storage connector

Now let us consider a few scenarios to understand some of the functionalities available with this integration. You can make use of the connector actions by adding the connector from an Action Flow or a Workflow. You can also use the Bind Data to fetch data from the connector.

Now when you want to use the Google Cloud Storage connector within your Apps, you can go to the UI Builder > Connectors > Connected tab. Here all connectors that have accounts configured or in other words, are connected will be listed out. If you click Manage Account, you can see the list of all available actions for the connector. You would need to add the action whenever you want to define further actions. Once you have fetched the data using the respective action, you can make use of the Bind Data to fetch data into a control.

Using Connector

Get a list of buckets

Let us consider a very simple example to fetch a list of buckets from your Google Cloud Storage account and use it to provide options using a dropdown control. Add a Dropdown control and go to Bind data. Click Select Connector where you would get a list of Connectors. Select Google Cloud Storage and click Continue. You get the list of available actions for the connector.

Select GetBuckets and click Continue. Select the Account to authenticate.

Add the connector name. Now if you want to transform response or add transform keys you can make the necessary changes and updates here and click Test & Finish.

Once the configuration is done you need to select the keys to be used to display data under the Bind Data option. Click Save.

When you run the form you can get the list of buckets from your Google Cloud Storage.

List Objects in a Bucket

Continuing with the same example to get a list of buckets, you can use the selected bucketname from the Dropdown control and use it to display the list of objects from the selected bucket.

  • So add a Tablegrid control and then click Bind Data. Add a connector and select the action as GetFiles. Select the Configured account.

  • You need to provide the Bucket name from where you would list out the objects. Select the dropdown control name from the Use Keywords.

  • Test the connection and click Test & Finish.

  • Under Bind Data, select the Keys to get the data from the connector.

    kyes connector

  • Now, whenever you take a preview, note that the objects for the selected Bucket are listed out.

Uploading files to the bucket

There can be different scenarios where you would find it useful to upload files, may it be to store large numbers of supporting documentation as images or PDFs or to say take a backup and store files to the Google Cloud Storage bucket and so on. You can make use of the Google Cloud Storage connector’s UploadFile action for this purpose.

Let us assume that we have a form where we select the Bucket name from the dropdown (optional can also use the folder name) to upload the files to, and the File upload control to enable uploading of the file/s. Let us add an action button that triggers the action flow to upload files.

  • In this situation on the button_click event of the action button, you would add the Server-side action > Google Cloud Storage connector and choose the action UploadFile and click Continue.

  • Select the Connected account and click Continue.

  • Use the Dropdown control to get the Bucketname from the Use keywords, add the folder name (which is optional), and provide the Files using the Fileupload control’s name from the Use keywords. Click Continue. You can also add file permissions…

  • Add the action name and provide the variable that returns the URL. Note that the Media link may not be accessible depending on the access right. You can however use GetPre-signed URL action to access the same.

  • If you want you can use this variable to display the URL in a text control for the sake of understanding. You can see the selected bucket to which your file is uploaded.

Generating a pre-signed URL

At times you may want to allow your customers to get a specific object to your bucket for a limited period without security credentials, then in that case you need to generate a pre-signed URL that allows you to temporarily share the URL without making it public. You can use the action available GetPreSignedUrl to enable using the URL.

Let us take the example where you select the Bucket name from the list of available buckets and display the files and folders in the table grid control.

  • When you select the file the action is triggered that is defined under action1_click.
  • Select the Bucketname from the Use Keywords, get the Filename or Object’s Key Name from the tablegrid as seen in the illustration above, and provide the time in seconds after which the link expires.

So now whenever you run the form the URL is returned as a response variable which will be shown in the text control.