<a id="sftp-binary-file-source-connector"></a>

# Binary File Source Connector for Confluent Platform

The Kafka Connect Binary File Source connector monitors the SFTP directory specified in `input.path` for files and reads them as binaries, forwarding the complete contents of each file as a binary record value.  The recommended converter to use is the [ByteArrayConverter](/platform/current/connect/concepts.html#converters).

```properties
value.converter=org.apache.kafka.connect.converters.ByteArrayConverter
```

To use this connector, specify the name of the connector class in the `connector.class` configuration property.

```properties
connector.class=io.confluent.connect.sftp.SftpBinaryFileSourceConnector
```

<a id="sftp-binary-file-source-connector-example"></a>

## Binary File Source Connector Example

This example follows the same steps as the Quick Start. Review the [Quick Start](overview.md#sftp-source-connector-quickstart) for help running the Confluent Platform and installing the SFTP connector package.

Prerequisites
: - [Confluent Platform](/platform/current/installation/index.html)
  - [Confluent CLI](https://docs.confluent.io/confluent-cli/current/installing.html) (requires separate installation)

1. Generate an HTML file using the command below:
   ```bash
   echo $'"<html>\n <head>\n </head>\n <body>\n   <h1>Hello World<h1>\n </body>\n</html>"' > "hello_world.html"
   ```
2. Create an `sftp.properties` file with the following contents:
   ```properties
   name=BinaryFileSftp
   tasks.max=1
   connector.class=io.confluent.connect.sftp.SftpBinaryFileSourceConnector
   input.path=/path/to/data
   error.path=/path/to/error
   finished.path=/path/to/finished
   input.file.pattern=hello_world.html
   behavior.on.error=IGNORE
   sftp.username=username
   sftp.password=password
   sftp.host=localhost
   sftp.port=22
   kafka.topic=sftp-binary-file-topic
   value.converter=org.apache.kafka.connect.storage.ByteArrayConverter
   ```
3. Load the SFTP Binary File Source connector using the Confluent CLI [confluent local services connect connector load](https://docs.confluent.io/confluent-cli/current/command-reference/local/services/connect/connector/confluent_local_services_connect_connector_load.html) command.
   ```bash
   confluent local load BinaryFileSftp --config sftp.properties
   ```

## Binary File Source Connector Example (Avro)

The following example loads a binary file into a specific field in an Avro-formatted message using the Hoist SMT.

1. Generate an HTML file using the command below:
   ```bash
   echo $'"<html>\n <head>\n </head>\n <body>\n   <h1>Hello World<h1>\n </body>\n</html>"' > "hello_world.html"
   ```
2. Create an `sftp.properties` file with the following contents:
   ```properties
   name=BinaryFileSftp
   tasks.max=1
   connector.class=io.confluent.connect.sftp.SftpBinaryFileSourceConnector
   input.path=/path/to/data
   error.path=/path/to/error
   finished.path=/path/to/finished
   input.file.pattern=hello_world.html
   behavior.on.error=IGNORE
   sftp.username=username
   sftp.password=password
   sftp.host=localhost
   sftp.port=22
   kafka.topic=sftp-binary-file-avro-topic
   value.converter=io.confluent.connect.avro.AvroConverter
   transforms=HoistField
   transforms.HoistField.type=org.apache.kafka.connect.transforms.HoistField$Value
   transforms.HoistField.field=contents
   ```
3. Load the SFTP Binary File Source connector using the Confluent CLI [confluent local services connect connector load](https://docs.confluent.io/confluent-cli/current/command-reference/local/services/connect/connector/confluent_local_services_connect_connector_load.html) command.
   ```bash
   confluent local load BinaryFileSftp --config sftp.properties
   ```

   #### IMPORTANT
   - The [confluent local](https://docs.confluent.io/confluent-cli/current/command-reference/local/index.html) commands are intended for a single-node development environment and
     are not suitable for a production environment. The data that are produced are transient and are intended to be
     temporary. For production-ready workflows, see [Install and Upgrade Confluent Platform](/platform/current/installation/index.html).

<a id="sftp-binary-file-source-connector-config"></a>

## Configuration Properties

For connector-specific configuration properties, see
[SFTP Source Connector Configuration Properties](license_config.md#sftp-source-connector-license-config).
