How to use the OCI Object Storage from the Oracle Integration Cloud

 Article originally posted in the Oracle Integration Blog.

The Oracle Cloud Infrastructure (OCI) offers a great set of services that can be very useful in combination with the Oracle
Integration Cloud (OIC) for a wide variety of use cases. Things like the Object Storage, Oracle Streaming Service, Functions etc, can easily be accessed from OIC. The OCI ecosystem has a rich set of API’s that can be used for that purpose –
https://docs.cloud.oracle.com/en-us/iaas/api/#/

In this post I am going to show how to create a file in the Oracle Object Storage.

What is the Object Storage

“The Oracle Cloud Infrastructure Object Storage service is an internet-scale,high-performance storage platform that offers reliable and cost-efficient data durability. The Object storage service can store an unlimited amount of unstructured data of any content type, including analytic data and rich content, like images and videos.”

Traditional integration use cases rely heavily on File Servers and SFTP access as an harbour for files. Object Storage and similar services are picking up fast in replacing them. We see more and more customers leveraging the benefits of these services for the handling of all different types of content that need to be stored and moved.

How to Start

Before jumping to the Integration Cloud, we need to create an object storage bucket and we need API signing keys.

Create an Object Storage Bucket

Some important definitions:

Bucket – A logical container for storing objects

Namespace – A logical entity that serves as a top-level container for all buckets and  objects, allowing you to control bucket naming within your tenancy. Each Oracle Cloud Infrastructure tenant is assigned one unique and uneditable Object storage namespace that spans all compartments within a region

ObjectAny type of data, regardless of content type, is stored as an object. The object is composed of the object itself and metadata about the object. Each object is stored in a bucket.

In the Oracle Console go to Object Storage->Create Bucket

Provide a name and you can leave everything else
as default.

As simple as it gets, you now have a Bucket.

You can also see the Namespace – please make a note of this as it will be required in the next steps.

Create a set of API Signing Keys

In order to be able to use any of OCI’s API’s we need an API Signing Key:

https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm

In the Oracle Console go to Identity->Users->User Details>API Keys


You need to generate a pair of keys – see here how (Instructions for Linux/Mac and Windows)!

Upload your public key.

And now you are ready to jump into OIC!

Create a REST Connection

You will need to collect some information in order to fill the required parameters.

Connection Type REST API Base URL
Connection URL https://objectstorage.<region>.oraclecloud.com
Security OCI Signature Version 1
Tenancy OCID https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#five
User OCID https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#five
Private Key The private key from the previous step
Fingerprint https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three

For this demo use case I will create an AppDriven Orchestration with:

  • REST Trigger
  • FTP Connection to read a
    file 
  • Pass the file to the REST OCI
    Object Storage invocation.
  • Return a response

Nothing fancy as this is just a capability showcase 😊

For the REST Trigger, no need to have input parameters but we do define a response.The response requires a payload format – JSON Sample

A simple response definition with Result as the parameter to be returned.

Then we drag the FTP Connection with Read File operation where we pass the Input Directory and the File Name.

I am using the OIC FTP Server – for more information please check these 2 posts!

https://blogs.oracle.com/integration/embedded-file-server-sftp-in-oracle-integration

https://blogs.oracle.com/integration/leveraging-oracle-integration-file-server-for-file-based-integrations-v2

Finally the interesting part – we drag the REST OCI  connection (created previously) into the canvas.

How to know the URI for this? Well, we need to read the OCI
API Documentation
.

The method I will use is the PutObject which has the following URI:

/n/{namespaceName}/b/{bucketName}/o/{objectName}

In a real life scenario I would not pass any of these values directly as I am doing here, it would be an input parameter or a lookup instead.

The other relevant part is the configuration of the request payload. We select the “Send Attachments in request” with a binary format and media-type as application/octet-stream

The last piece of this puzzle is mapping the file reference from the FTP Response to the input of the request that creates a file in the Object Storage. We could potentially read the contents of the file and perform some transformation, but here we simply pass it as a reference (much easier).

The last mapping required is the one for the Trigger REST response. 

The Integration looks like thisAfter activating it and using the embedded test functionality (for REST Triggers) we can easily execute the Integration, and verify each step with the Activity Stream.

And that was it – the file was created in the Object Storage!
Easy, yet powerful !