# File Adapter

## <mark style="color:blue;">Architecture</mark>

### File Step Processor

<figure><img src="https://3732705674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaQ7wCJOT0ZaejHUiD6sb%2Fuploads%2FIUFq0baRp5HJQeh1a7Zm%2FfileStepProcessor.drawio%20(2).png?alt=media&#x26;token=04653bf4-d2de-46db-b1fb-244a2d7cf561" alt=""><figcaption></figcaption></figure>

### Batch File Step Processor

<figure><img src="https://3732705674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaQ7wCJOT0ZaejHUiD6sb%2Fuploads%2FPVvnnYCYOBSHCRMCn2Ft%2FbatchFileSTepProcessor.drawio%20(1).png?alt=media&#x26;token=b2c87fc7-1fc1-4a74-ad4b-44e81ceee754" alt=""><figcaption></figcaption></figure>

### File Create Step Processor

<figure><img src="https://3732705674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaQ7wCJOT0ZaejHUiD6sb%2Fuploads%2FYTnVAI26Qh3C52cl4yXx%2Ffilecreate.drawio%20(2).png?alt=media&#x26;token=d474ca85-7254-4da9-9d47-1b9773e6eefe" alt=""><figcaption></figcaption></figure>

### File Merge Step Processor

<figure><img src="https://3732705674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaQ7wCJOT0ZaejHUiD6sb%2Fuploads%2FzOEqvFwyIv3HDYjlQkrX%2Ffilemerge.drawio%20(2).png?alt=media&#x26;token=a30664bb-23c0-4ddf-aa8b-f84e8ed6d28d" alt=""><figcaption></figcaption></figure>

### File Splitter Step Processor

<figure><img src="https://3732705674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaQ7wCJOT0ZaejHUiD6sb%2Fuploads%2FYWNDriKykWTbHpUw3l8e%2FfileSplitter.drawio%20(3).png?alt=media&#x26;token=29960ed9-63f8-48b5-b9d5-cd69e0130fd2" alt=""><figcaption></figcaption></figure>

## <mark style="color:blue;">Functionality</mark>

The file adapter is utilized for accessing and manipulating file data through the FTP/SFTP channel. To access the channel, basic information is passed through the step path, and the appropriate adapter is selected depending on the requirement. Function-wise, the file adapter is separated into five different adapters. Each adapter inherits the file handler, which includes the business logic for accessing and manipulating files such as counting, reading, moving, splitting, merging, uploading, and creating files.

For instance, in the file step processor adapter, the first step is to retrieve the parameters from the step path for channel connection. These parameters include Host, port, Username, Password, BaseDir, NewDir, InprocessDir, and ProcessedDir. The adapter attempts to establish a connection to the channel and counts the number of files in the relevant folder using the file handler. If the count value does not exceed the specified count, the file is read using the file handler.readFile() method, which returns a list of file names. If the response list is not empty or null, the file names are returned.

## <mark style="color:blue;">Capabilities</mark>

* **TYPE OF PROTOCOLS: FTP / SFTP / S3**
* **TYPE OF FILES:  CSV/EXCEL/TXT**
* **SIZE OF A FILE:** Less than 12MB
* **ALLOWED DELIMITERS:  |, Tab**
* **REQUIRED PARAMETERS:** Host, Port, UserName, Password, BaseDirectory, NewDirectory, ProcessedDirectory, InProcessedDirectory&#x20;

## <mark style="color:blue;">File Handlers</mark>

<details>

<summary><a href="https://oresund-integration-platform.gitbook.io/oresund-integration-platform/about/product-and-developer-guide/adapters/file-adapter/ftp-handler">FTP HANDLER</a></summary>



</details>

<details>

<summary><a href="https://oresund-integration-platform.gitbook.io/oresund-integration-platform/about/product-and-developer-guide/adapters/file-adapter/sftp-handler">SFTP HANDLER</a></summary>



</details>

<details>

<summary><a href="https://oresund-integration-platform.gitbook.io/oresund-integration-platform/about/product-and-developer-guide/adapters/file-adapter/excel-ftp-and-sftp-handler">EXCEL FTP/SFTP HANDLER</a></summary>



</details>
