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
Object - Any 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:
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.
REST API Base URL
OCI Signature Version 1
The private key from the previous step
For this demo use case I will create an AppDriven Orchestration with:
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!
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:
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 this
After activating it and using the embedded test functionality (for REST Triggers) we can easily execute the Integration, and verify each step with the Activity StreamAnd that was it – the file was created in the Object Storage!
Easy, yet powerful !