> For the complete documentation index, see [llms.txt](https://docs.selfuel.digital/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.selfuel.digital/data-integration-with-nexus/nexus-elements/connectors/source/ftpfile.md).

# FtpFile

> Ftp file source connector

### Key features[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#key-features) <a href="#key-features" id="key-features"></a>

* [x] &#x20;batch
* [ ] &#x20;stream
* [ ] &#x20;exactly-once
* [x] &#x20;column projection
* [x] &#x20;parallelism
* [ ] &#x20;support user-defined split
* [x] &#x20;file format type
  * [x] &#x20;text
  * [x] &#x20;csv
  * [x] &#x20;json
  * [x] &#x20;excel
  * [x] &#x20;xml
  * [x] &#x20;binary

### Description[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#description) <a href="#description" id="description"></a>

Read data from ftp file server.

### Options[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#options) <a href="#options" id="options"></a>

| name                         | type    | required | default value       |
| ---------------------------- | ------- | -------- | ------------------- |
| host                         | string  | yes      | -                   |
| port                         | int     | yes      | -                   |
| user                         | string  | yes      | -                   |
| password                     | string  | yes      | -                   |
| path                         | string  | yes      | -                   |
| file\_format\_type           | string  | yes      | -                   |
| connection\_mode             | string  | no       | active\_local       |
| delimiter/field\_delimiter   | string  | no       | \001                |
| read\_columns                | list    | no       | -                   |
| parse\_partition\_from\_path | boolean | no       | true                |
| date\_format                 | string  | no       | yyyy-MM-dd          |
| datetime\_format             | string  | no       | yyyy-MM-dd HH:mm:ss |
| time\_format                 | string  | no       | HH:mm:ss            |
| skip\_header\_row\_number    | long    | no       | 0                   |
| schema                       | config  | no       | -                   |
| sheet\_name                  | string  | no       | -                   |
| xml\_row\_tag                | string  | no       | -                   |
| xml\_use\_attr\_format       | boolean | no       | -                   |
| file\_filter\_pattern        | string  | no       | -                   |
| compress\_codec              | string  | no       | none                |
| encoding                     | string  | no       | UTF-8               |
| common-options               |         | no       | -                   |

#### host \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#host-string) <a href="#host-string" id="host-string"></a>

The target ftp host is required

#### port \[int][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#port-int) <a href="#port-int" id="port-int"></a>

The target ftp port is required

#### user \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#user-string) <a href="#user-string" id="user-string"></a>

The target ftp user name is required

#### password \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#password-string) <a href="#password-string" id="password-string"></a>

The target ftp password is required

#### path \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#path-string) <a href="#path-string" id="path-string"></a>

The source file path.

#### file\_format\_type \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#file_format_type-string) <a href="#file_format_type-string" id="file_format_type-string"></a>

File type, supported as the following file types:

`text` `csv` `parquet` `orc` `json` `excel` `xml` `binary`

If you assign file type to `json` , you should also assign schema option to tell connector how to parse data to the row you want.

For example:

upstream data is the following:

```

{"code":  200, "data":  "get success", "success":  true}

```

you should assign schema as the following:

```

schema {
    fields {
        code = int
        data = string
        success = boolean
    }
}

```

connector will generate data as the following:

| code | data        | success |
| ---- | ----------- | ------- |
| 200  | get success | true    |

If you assign file type to `text` `csv`, you can choose to specify the schema information or not.

For example, upstream data is the following:

```

tyrantlucifer#26#male

```

If you do not assign data schema connector will treat the upstream data as the following:

| content               |
| --------------------- |
| tyrantlucifer#26#male |

If you assign data schema, you should also assign the option `field_delimiter` too except CSV file type

you should assign schema and delimiter as the following:

```

field_delimiter = "#"
schema {
    fields {
        name = string
        age = int
        gender = string 
    }
}

```

connector will generate data as the following:

| name          | age | gender |
| ------------- | --- | ------ |
| tyrantlucifer | 26  | male   |

If you assign file type to `binary`, Nexus can synchronize files in any format, such as compressed packages, pictures, etc. In short, any files can be synchronized to the target place. Under this requirement, you need to ensure that the source and sink use `binary` format for file synchronization at the same time. You can find the specific usage in the example below.

#### connection\_mode \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#connection_mode-string) <a href="#connection_mode-string" id="connection_mode-string"></a>

The target ftp connection mode , default is active mode, supported as the following modes:

`active_local` `passive_local`

#### delimiter/field\_delimiter \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#delimiterfield_delimiter-string) <a href="#delimiterfield_delimiter-string" id="delimiterfield_delimiter-string"></a>

**delimiter** parameter will deprecate after version 2.3.5, please use **field\_delimiter** instead.

Only need to be configured when file\_format is text.

Field delimiter, used to tell connector how to slice and dice fields.

default `\001`, the same as hive's default delimiter

#### parse\_partition\_from\_path \[boolean][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#parse_partition_from_path-boolean) <a href="#parse_partition_from_path-boolean" id="parse_partition_from_path-boolean"></a>

Control whether parse the partition keys and values from file path

For example if you read a file from path `ftp://hadoop-cluster/tmp/nexus/parquet/name=tyrantlucifer/age=26`

Every record data from file will be added these two fields:

| name          | age |
| ------------- | --- |
| tyrantlucifer | 26  |

Tips: **Do not define partition fields in schema option**

#### date\_format \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#date_format-string) <a href="#date_format-string" id="date_format-string"></a>

Date type format, used to tell connector how to convert string to date, supported as the following formats:

`yyyy-MM-dd` `yyyy.MM.dd` `yyyy/MM/dd`

default `yyyy-MM-dd`

#### datetime\_format \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#datetime_format-string) <a href="#datetime_format-string" id="datetime_format-string"></a>

Datetime type format, used to tell connector how to convert string to datetime, supported as the following formats:

`yyyy-MM-dd HH:mm:ss` `yyyy.MM.dd HH:mm:ss` `yyyy/MM/dd HH:mm:ss` `yyyyMMddHHmmss`

default `yyyy-MM-dd HH:mm:ss`

#### time\_format \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#time_format-string) <a href="#time_format-string" id="time_format-string"></a>

Time type format, used to tell connector how to convert string to time, supported as the following formats:

`HH:mm:ss` `HH:mm:ss.SSS`

default `HH:mm:ss`

#### skip\_header\_row\_number \[long][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#skip_header_row_number-long) <a href="#skip_header_row_number-long" id="skip_header_row_number-long"></a>

Skip the first few lines, but only for the txt and csv.

For example, set like following:

`skip_header_row_number = 2`

then Nexus will skip the first 2 lines from source files

#### schema \[config][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#schema-config) <a href="#schema-config" id="schema-config"></a>

Only need to be configured when the file\_format\_type are text, json, excel, xml or csv ( Or other format we can't read the schema from metadata).

The schema information of upstream data.

#### read\_columns \[list][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#read_columns-list) <a href="#read_columns-list" id="read_columns-list"></a>

The read column list of the data source, user can use it to implement field projection.

#### sheet\_name \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#sheet_name-string) <a href="#sheet_name-string" id="sheet_name-string"></a>

Reader the sheet of the workbook,Only used when file\_format\_type is excel.

#### xml\_row\_tag \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#xml_row_tag-string) <a href="#xml_row_tag-string" id="xml_row_tag-string"></a>

Only need to be configured when file\_format is xml.

Specifies the tag name of the data rows within the XML file.

#### xml\_use\_attr\_format \[boolean][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#xml_use_attr_format-boolean) <a href="#xml_use_attr_format-boolean" id="xml_use_attr_format-boolean"></a>

Only need to be configured when file\_format is xml.

Specifies Whether to process data using the tag attribute format.

#### compress\_codec \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#compress_codec-string) <a href="#compress_codec-string" id="compress_codec-string"></a>

The compress codec of files and the details that supported as the following shown:

* txt: `lzo` `none`
* json: `lzo` `none`
* csv: `lzo` `none`
* orc/parquet:\
  automatically recognizes the compression type, no additional settings required.

#### encoding \[string][​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#encoding-string) <a href="#encoding-string" id="encoding-string"></a>

Only used when file\_format\_type is json,text,csv,xml. The encoding of the file to read. This param will be parsed by `Charset.forName(encoding)`.

#### common options[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#common-options) <a href="#common-options" id="common-options"></a>

Source plugin common parameters, please refer to [Source Common Options](/data-integration-with-nexus/nexus-elements/connectors/source/source-common-options.md) for details.

### Example[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#example) <a href="#example" id="example"></a>

```

  FtpFile {
    path = "/tmp/nexus/sink/text"
    host = "192.168.31.48"
    port = 21
    user = tyrantlucifer
    password = tianchao
    file_format_type = "text"
    schema = {
      name = string
      age = int
    }
    field_delimiter = "#"
  }

```

#### Transfer Binary File[​](https://seatunnel.apache.org/docs/2.3.7/connector-v2/source/FtpFile#transfer-binary-file) <a href="#transfer-binary-file" id="transfer-binary-file"></a>

```

env {
  parallelism = 1
  job.mode = "BATCH"
}

source {
  FtpFile {
    host = "192.168.31.48"
    port = 21
    user = tyrantlucifer
    password = tianchao
    path = "/nexus/read/binary/"
    file_format_type = "binary"
  }
}
sink {
  // you can transfer local file to s3/hdfs/oss etc.
  FtpFile {
    host = "192.168.31.48"
    port = 21
    user = tyrantlucifer
    password = tianchao
    path = "/nexus/read/binary2/"
    file_format_type = "binary"
  }
}
```
