# New File

### Overview

The **New File Component** monitors an FTP or SFTP server for newly created files and directories within a specified path, enabling workflows to react dynamically to file changes.

### Usage

This component connects to an FTP/SFTP server, watches a directory for new files and folders, and emits metadata whenever a new item appears.

#### Properties

| Property | Type     | Description                                                 |
| -------- | -------- | ----------------------------------------------------------- |
| `path`   | `string` | The directory path to monitor for new files or directories. |

#### Output Ports

| Port  | Description                                             |
| ----- | ------------------------------------------------------- |
| `out` | Emits metadata for newly detected files or directories. |

#### Processing Logic

1. **Establishes FTP/SFTP Connection**: Connects securely to the remote server using authentication credentials.
2. **Monitors Directory for Changes**:
   * Lists all current files in the specified path.
   * Compares against previously seen files.
   * Detects new files and directories.
3. **Handles Detected Changes**:
   * If new files or directories are found, outputs their metadata to the `out` port.
   * Saves the current state for future comparisons.
4. **Closes Connection**: Ensures the connection is terminated after execution.

#### Output Data Schema

| Property        | Type     | Description                            |
| --------------- | -------- | -------------------------------------- |
| `name`          | `string` | Name of the new file or directory.     |
| `size`          | `number` | Size of the file in bytes.             |
| `type`          | `string` | Indicates if it's a file or directory. |
| `modifiedAt`    | `number` | Timestamp of the last modification.    |
| `permissions`   | `string` | File permissions.                      |
| `hardLinkCount` | `number` | Number of hard links to the file.      |
| `link`          | `string` | Link to the file, if applicable.       |
| `group`         | `string` | Group ownership of the file.           |
| `user`          | `string` | User ownership of the file.            |
| `uniqueID`      | `string` | Unique identifier of the file.         |

### Notes

* **Supports FTP & SFTP**: Works with both FTP and secure FTP (SFTP) servers.
* **Automated File Monitoring**: Continuously detects and processes new files or directories.
* **Error Handling**: Ensures reliable detection by maintaining a known file state.

This component is useful for workflows requiring automatic response to file additions in remote directories.
