Google Cloud Storage allows world-wide storage and retrieval of any amount of data at any time. You can use Google Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.
Google Cloud Storage Connector 1.0.0
The Anypoint connector for Google Cloud Storage connector enables developers to use the Google Cloud Storage platform on MuleSoft Anypoint Runtime.
The Google Cloud Storage Connector is used to connect to the Google Cloud Storage. You can visit the Google Cloud Storage API here.
MuleSoft maintains the Premium connector under the Certified support policy.
Prerequisites
This document assumes that you are familiar with Mule, Anypoint Connectors, and Anypoint Studio. To increase your familiarity with Studio, consider completing a Anypoint Studio Tutorial. This page requires some basic knowledge of Mule Concepts, Elements in a Mule Flow, and Global Elements.
You will also require Anypoint Studio downloaded and installed on your development machine.
You will also need an account with Google Cloud Storage.
Hardware and Software Requirements
For hardware and software requirements, please visit the Hardware and Software Requirements page.
Compatibility
Software |
Version |
Mule Runtime |
3.8.X all versions |
Google Cloud Storage Library |
0.9.2-beta |
Java |
1.7 and later |
How to Install
You can install the connector in Anypoint Studio using the instructions in Installing a Connector from Anypoint Exchange.
How to Configure
To use the Google Cloud Storage connector in your Mule application, you must define a Global Element that can be used by one or many Google Cloud Storage message processor instances in an application or shared domain for connector user authentication and subsequent authorized use (read more about Global Elements).
Setting up Access to the Google Cloud Storage Service
The Google Cloud Storage service can be accessed once a connection is established with a service account.
Creating Global Element for the Google Cloud Storage Connector Configuration
-
Click the Global Elements tab at the base of the Anypoint Studio canvas.
-
On the Global Mule Configuration Elements screen, click Create.
-
Type
Google Cloud Storage
into the Search bar. -
In the Choose Global Type wizard, expand Connector Configuration and select the
Google Cloud Storage: JSON Service Account
-
Click OK.
-
Configure the parameters according to the table below.
Field Description JSON Service Account File Location
Enter the JSON location with your Google Cloud Storage credentials.
Project ID
Enter the corresponding project ID.
Required Connector Namespace and Schema
When designing your application in Anypoint Studio, when you drag the connector from the palette onto the Anypoint Studio canvas, Studio automatically populates the XML code with the connector namespace and schema location.
Namespace: http://www.mulesoft.org/schema/mule/google-cloud-storage
Schema Location: http://www.mulesoft.org/schema/mule/connector/current/mule-google-cloud-storage.xsd
Tip
|
If you are manually coding the Mule application in Studio’s XML editor or another text editor, define the namespace and schema location in the header of your Configuration XML, inside the <mule> tag.
|
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:connector="http://www.mulesoft.org/schema/mule/connector"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/google-cloud-storage
http://www.mulesoft.org/schema/mule/google-cloud-storage/current/mule-google-cloud-storage.xsd">
<!-- put your global configuration elements and flows here -->
</mule>
Maven Dependency Information
For Maven dependency management, include this XML snippet in your pom.xml
file.
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>google-cloud-storage-connector</artifactId>
<version>1.0.0</version>
</dependency>
Common Use Cases
Upload Blob into Bucket
-
Drag an File Endpoint into a new flow, and configure the file endpoint as follows:
Field Value Display Name
File (or any other name you prefer)
Path
Path from which to pick the files
Move to Directory
(optional) Directory into which files are moved after being processed
Connector Configuration
(Optional) A configuration of a file connector
-
Drag the Google Cloud Storage connector onto the canvas, then click on the message processor and from beneath
Basic Settings
select the+
symbol to add the Global Connector element. -
Configure the connector settings, click on
Test Connection
to test that the connection configured works fine and then click onOK
. -
Click on the Google Cloud Storage message processor that was dragged and select the
Create Blob
operation. -
Set
Blob Info Reference
to#[flowVars['BlobInfo']]
-
Add a Dataweave transformer after the file endpoint to create a BlobInfoPojo to pass on to the connector.
-
Click on DataWeave message processor, and select
edit
and change the output to beVariable
and enterBlobInfo
as the variable name. -
In the dataweave Output click
Define MetaData
, In the new window that appears click on the add button, in the type id enter "BlobInfoPojo", Click ok, under type selectJava
, UnderData structure
selectJava
, in the new window that appears search forBlobInfoPojo
, select it and click ok. -
Drag the
originalFileName
from the input tab to thename
(under blobId) on the output pane. -
Double click on the
bucket
parameter underblobid
, in the Dataweave editor hardcode the bucket name (i.e.bucket: "myBucketName"
). -
Since the connector returns a
Blob
object and the inbound endpoint does not require any response we can either transform the Object to Json with Dataweave or set the payload to an empty string (to avoid transformation exceptions). -
Run the project as a Mule Application (right-click project name, then select Run As > Mule Application).
-
The Mule application should read any files in the path specified and should upload them to the Google Cloud Storage.
Resources
-
Visit the Google Cloud Storage Connector Release Notes page for the release notes of the connector.
-
Visit the Google Cloud Storage Connector API Reference page for the technical documentation of the connector.
-
Visit Google Cloud Storage Documentation page for information on Google Cloud Storage.
-
Learn how to Install and Configure Anypoint™ Connectors in Anypoint™ Studio here.
-
Access MuleSoft’s forum to pose questions and get help from Mule’s broad community of users.
-
To access MuleSoft’s expert support team, subscribe to Mule ESB Enterprise and log in to MuleSoft’s Customer Portal.
-
Contact the connector developers at Ricston