Monday, 8 February 2021

ORACLE OIC - OCI Object Storage List and Download Files

We can use the REST adapter to invoke the 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. 



To Upload Files to OS

Context URL to Use : /n/telenet/b/{bucket_name}/o/{object_name}

Operation : PUT

Select Request Parameter and Request Payload option.

Select the request type as BINARY.

curl --verbose -X PUT https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/{tenancy}/b/{bucket_name}/o/{object_name} \

 -H "Authorization: [authorization-value]" \

 -H "Content-Type: application/octet-stream" \

 --data-binary "@file.ext" 



No comments:

Post a Comment

ERP - GL - Chart Of Accounts

Segments in General Ledger   Segments  are dimensions used to represent an account in a financial system. A company can have anywhere from...