AI News Hub Logo

AI News Hub

How to Accept Binary Format Files Directly in Oracle Integration Cloud (OIC) and Return JSON Response from SFTP

DEV Community
Naveen

Overview In Oracle Integration Cloud (OIC), there are scenarios where we need to receive files directly from an external application through a REST API and then place those files into an SFTP location. Usually, files like CSV, ZIP, PDF, or other binary content are handled as file-based data. In this blog, we will see how to configure an OIC integration to accept a binary file as input through a REST trigger, write that file to SFTP in binary mode, and finally return a successful JSON response with file details. Use Case Expose a REST endpoint in OIC. Accept a file directly as a binary payload. Write the received binary file to an SFTP directory. Return a JSON response containing file details such as: File name Directory Status Uploaded date This approach is useful when the source system sends the file directly in the REST request body instead of sending file content as Base64 or multipart form data. High-Level Flow Prerequisites Oracle Integration Cloud instance access REST connection with Trigger role SFTP connection configured successfully Target SFTP directory details Required file naming convention Sample JSON response structure Step 1: Create REST Connection with Trigger Role Trigger This REST connection will be used to expose the integration as an API endpoint. Step 2: Create and Test SFTP Connection SFTP host Port Username Password or private key Known host key details, if applicable After entering the required details, test the connection. Step 3: Create App-Driven Orchestration Integration Step 4: Configure REST Trigger Operation Configure the REST trigger with a POST operation. In the request configuration, select the request payload format as:Binary In the REST trigger configuration, mention the content type as:Other Media Type Then provide the media type as:application/csv If you are handling other file types, you can change the media type accordingly. application/pdf application/zip application/octet-stream text/csv Step 5: Configure REST Response as JSON In the response part of the REST trigger, select the response payload format as:JSON Sample Step 6: Add SFTP Adapter in the Integration Flow Write Step 7: Configure Target Directory and File Name Provide the target SFTP directory where the file should be written. You can provide the file name directly in the SFTP configuration or dynamically map it later in the mapper. Map REST Binary Payload to SFTP Write Now open the mapper between the REST trigger and SFTP write activity. Map SFTP Response to REST Response After the SFTP write operation is completed, map the response from the SFTP activity to the REST response mapper. Conclusion