Monday, 8 February 2021

ORACLE OIC - OCI Object Storage List and Download Files

We can use REST adapter to invoke OCI Object Storage API's to list the files under a given bucket and download the files. 

Following API will provide all the files with a specific prefix. 

/n/{tenancy_name}/b/{bucket_name}/o/

Operation = GET.

Add a request parameter . 

Name = prefix 

Type = string. 

Note:  In the request mapping provide the values for tenancy_name , bucket_name and prefix elements. 


Use the following sample JSON response message to receive and parse the response message. 

Sample Response Message : 

{

  "objects" : [ {

    "name" : "1MB.data"

  } ]

}




If there are files in object storage then response will return an array of file names. Use the loop activity to loop over each file and download the file from Object Storage. 

To download the file use the following rest URI and GET operation. 

/n/{tenancy_name}/b/{bucket_name}/o/{object_name}

While defining response type select Binary value this will auto select media type.  



Use the response and write a file using stage activity.  Use an opaque schema element to write a file. 

While mapping , user the reference element from OCI response and add reference encoding function and map it to write schema element. 




No comments:

Post a Comment