X
April 26, 2019

Using Stage File Write operation(with opaque schema) to copy files

By: Namratha Narayan | Project Lead, SOA

Share

The stage file action can process each file downloaded by the FTP Adapter. The stage file action can read, write, zip, unzip, and list files in a staged location known to Oracle Integration Cloud. 

For example, you may include a stage file action in an integration as follows:

  • Configure an FTP Adapter with the following settings:

    • Download File operation

    • Unzip the File option

    • Input directory and download directory path

  • Because the ZIP file may contain multiple files, configure a for-each action below the FTP Adapter to iterate over repeated elements.

  • To read each file from the input directory, configure a stage file action below the for-each action to read each file from the input directory as follows:

    • In the Expression Builder, specify the file name and directory from which to read the file.

    • Specify the schema file by loading a file that contains the data structure.

  • To write files to a output directory, configure a stage file action below the for-each action to write each file to the output directory

 

Sample Flow

Sample IAR

Opaque Schema

This Integration

  • Downloads and stages the file temporarily in Oracle Integration Cloud using FTP Adapter 
  • Lists the files in input directory using Stage File action List Operation
  • Iterates over the files using for-each action 
  • Copies the files to output directory using Stage File action Write Operation and opaque schema

 

To configure the FTP Adapter

  1. On the right side of the canvas, click Invoke palette
  2. Drag an FTP Adapter into the integration canvas.
  • Specify a name

  • Select the Download File operation.

  • Specify the input directory and download directory path(this path will be input directory for stage file list).

  • Select the Unzip the File option.

 

To configure a stage file action

  • On the right side of the canvas, click Actions to expand the panel.
  • Drag the Stage File icon to the plus sign where you want to perform file actions.
    The Configure Stage File Action wizard is displayed.
  • Complete the fields on the Basic Info page, and click Next.
    The Configure Operation page is displayed.
    The Configure Operation page enables you to define the file operations to perform. You can select to list a file, read an entire file, read files in chunked sizes, unzip a file, write a file, or zip a file, You use the Expression Builder to build the specific details of your operation. The Expression Builder shows all upstream sources (including assignments, for-each actions, invoke connections, and so on) for you to specify these details.
  • To configure Stage File List Operation :
    From the drop-down list, select List File

Specify the Directory to List Files from

Click the Expression Builder icon to build an expression to specify the directory from which to list files.

Specify the File Pattern to use

Specify the pattern of the file name to transfer to the output directory. Click the ? icon for the list of supported patterns.

List Files Recursively

Select to list the files recursively.

  • To configure Stage File Write Operation :
    From the drop-down list, select Write File

Specify the File Name

Click the Expression Builder icon to build an expression to specify the file name.

Specify the Output Directory

Click the Expression Builder icon to build an expression to specify the output directory.

Append to Existing File

Optionally select to append records to the existing file.

The Schema Options page is displayed if you selected a read or write stage file operation.

  • To define the Schema File
    The Schema Options page enables you to define a schema. This page is displayed if you selected a read or write stage file operation.
Do you want to define a schema for this endpoint?

Select Yes to define a schema format to use for the files to transfer.

Do you want to create a new schema or use an existing one?

Select an existing schema from the file system: Select an existing schema file. On a subsequent page of this wizard, you are prompted to select the existing schema (XSD) file from the file system.

  • To define the Schema Format
    Based on your selection on the Schema Options page, the Format Definition page enables you to create a new schema from a comma-separated value (CSV) file or select an existing schema. 
    Select an Existing Schema from the File System
  • Select a New File

Select the existing schema file to use. This field appears if you selected an existing schema from the file system.

  • Selected File Name

Displays the selected schema file name.

  • Select the Schema Element

Select the schema element. This field is displayed after the schema file is selected. The element name is treated as the root element in the uploaded schema file.

Note: Opaque schema will return Base64 encoded string

 

To create a For-Each Action

  1. On the right side of the canvas, click Actions to expand the panel.

  2. Drag the For Each icon to the plus sign where you want to loop over an element.

    The For Each dialog is displayed.

  3. Expand the Source tree to select an element.

  4. Drag a repeatable element to the Repeating Element field. This is the element over which to loop.
    For this example, the element over which to loop is ICSFile.

  5. Enter a name in the Name field and an optional description of the action in the Description field.

    For every iteration of the loop, there is a single reference to the repeating element (ICSFile). A current element name file is required for this action to occur.

  6. Enter an alias for the current file of the iteration in the Current Element Name field. 

 

To modify data mapping

  1. Click the Mapper icon for the Map to Stage File Write.
  2. Click Edit to invoke the mapper.
  3. Make appropriate updates to the mappings.

Map the FileReference of the for-each repeating element (ICSFile) to opaqueElement of StageFileWrite using encodeReferenceToBase64 Function

 

 

Share