FTP数据源
更新时间:2026-07-03
FTP 文件数据源支持文件采集(Ftp-File)一类 source 插件,以 file 作业类型运行,可将 FTP 服务器上的文件写入数据卷、媒体集目标端(各目标端插件参数详见各自文档)。本文以数据卷作为目标端示例。
FTP 插件类型
| 插件 | plugin_name | _db_pluginId | 作业类型 | 说明 |
|---|---|---|---|---|
| FTP 文件采集 | FtpFile |
Ftp-File |
file |
从 FTP 服务器采集文件,支持路径过滤、格式过滤和时间范围过滤 |
脚本 Demo 与参数说明
一、文件任务:FTP → 数据卷
适用于将 FTP 服务器上的文件批量采集并写入 DataBuilder 数据卷的场景。作业类型为 file,source 使用 Ftp-File,sink 使用 Volume。
JSON
1{
2 "_db_jobMeta": {
3 "name": "ftp_orders_to_volume",
4 "description": "FTP /data/in/orders/ 目录下 CSV 文件同步到 Volume",
5 "parentFolderId": "project_91cc_799bd26eee94",
6 "type": "file",
7 "mode": "script"
8 },
9 "env": {
10 "job.mode": "BATCH",
11 "parallelism": 1,
12 "checkpoint.interval": 30000
13 },
14 "source": [
15 {
16 "plugin_name": "FtpFile",
17 "_db_pluginId": "Ftp-File",
18 "plugin_output": "source_file",
19 "_db_connectionId": "ftp-conn-001",
20 "path": "/data/in/orders/",
21 "connection_mode": "passive_local",
22 "file_filter_pattern": ".*\\.csv",
23 "filename_extension": "csv",
24 "_db_enableSourceFileFilterMod": "enabled",
25 "file_filter_modified_start": "${logicTime(yyyy-MM-dd,-1d)}",
26 "file_filter_modified_end": "${logicTime(yyyy-MM-dd,0d)}"
27 }
28 ],
29 "sink": [
30 {
31 "plugin_name": "Volume",
32 "_db_pluginId": "Volume",
33 "plugin_input": "source_file",
34 "_db_sinkPath": "/Volumes/lake/default/raw_files/orders/",
35 "duplicate_file_strategy": "OVERWRITE"
36 }
37 ]
38}
Reader 参数:Ftp-File
| 参数 | 描述 | 是否必选 | 默认值 |
|---|---|---|---|
plugin_name |
SeaTunnel 插件名,固定填 FtpFile |
是 | 无 |
_db_pluginId |
DataBuilder 侧插件 ID,固定填 Ftp-File |
是 | 无 |
plugin_output |
Source 输出流名称,需与 sink 的 plugin_input 保持一致 |
是 | 无 |
_db_connectionId |
FTP 数据源连接 ID | 是 | 无 |
path |
FTP 服务器上的文件或目录路径 | 是 | 无 |
connection_mode |
连接模式:active_local(主动模式)/ passive_local(被动模式) |
否 | active_local |
file_filter_pattern |
路径正则过滤,匹配的文件才会被采集(如 .*\\.csv) |
否 | 无 |
filename_extension |
文件格式过滤,例如 .png 或 .png,.jpg,.zip |
否 | 无 |
_db_enableSourceFileFilterMod |
更新时间过滤开关:disabled(不过滤)/ enabled(过滤) |
否 | disabled |
file_filter_modified_start |
文件最后修改时间下界,支持时间宏如 ${logicTime(yyyy-MM-dd,-7d)} |
否 | 无 |
file_filter_modified_end |
文件最后修改时间上界,支持时间宏如 ${logicTime(yyyy-MM-dd,0d)} |
否 | 无 |
配置编写注意事项
- plugin_name 与 _db_pluginId 不同:SeaTunnel 真实插件名为
FtpFile,DataBuilder 侧标识为Ftp-File,两者格式不同,注意区分。 - 连接模式选择:防火墙/NAT 环境下通常使用
passive_local(被动模式),若服务器在内网且可主动连接客户端则用active_local(主动模式)。 - 文件过滤组合使用:
file_filter_pattern(正则)和filename_extension(扩展名)可组合使用,均满足才会采集该文件;时间范围过滤需先将_db_enableSourceFileFilterMod设为enabled才生效。 - FTP 仅支持 file 作业类型:
env.job.mode固定为BATCH,不支持 streaming。
评价此篇文章
