FTP file output plugin for Embulk
This plugin support FTP, FTPES(FTPS explicit), FTPS(FTPS implicit) and doesn’t support SFTP.
If you want to use SFTP, please use embulk-output-sftp.
21
. 990
if ssl
is true and ssl_explicit
is false)""
)".%03d.%02d"
)ssl_trusted_ca_cert_file
but embed the contents of the PEM file as a string value instead of path to a local file (string, optional)FTP and FTPS server listens following port number(TCP) as default.
Please be sure to configure firewall rules.
FTP | FTPS(explicit) = FTPES | FTPS(implicit) = FTPS | |
---|---|---|---|
Control channel port | 21 | 21 | 990 (*1) |
Data channel port (*2) | 20 | 20 | 989 |
Simple FTP:
out:
type: ftp
host: ftp.example.net
port: 21
user: anonymous
path_prefix: /ftp/file/path/prefix
file_ext: csv
formatter:
type: csv.gz
header_line: false
encoders:
- {type: gzip}
FTPS encryption without server certificate verification:
out:
type: ftp
host: ftp.example.net
port: 21
user: anonymous
password: "mypassword"
ssl: true
ssl_verify: false
path_prefix: /ftp/file/path/prefix
file_ext: csv
FTPS encryption with server certificate verification:
out:
type: ftp
host: ftp.example.net
port: 21
user: anonymous
password: "mypassword"
ssl: true
ssl_verify: true
ssl_verify_hostname: false # to disable server hostname verification (optional)
# if the server use self-signed certificate, or set path to the pem file (optional)
ssl_trusted_ca_cert_file: /path/to/ca_cert.pem
# or embed contents of the pem file here (optional)
ssl_trusted_ca_cert_data: |
-----BEGIN CERTIFICATE-----
MIIFV...
...
...
-----END CERTIFICATE-----
path_prefix: /ftp/file/path/prefix
file_ext: csv
$ ./gradlew gem # -t to watch change of files and rebuild continuously
Firstly install Docker and Docker compose then docker-compose up -d
,
so that an FTP server will be locally launched then you can run tests with ./gradlew test
.
$ docker-compose up -d
Creating network "embulk-output-ftp_default" with the default driver
Creating embulk-output-ftp_server ... done
Creating embulk-output-ftps_server ... done
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------
embulk-output-ftp_server /usr/sbin/run-vsftpd.sh Up 20/tcp, 0.0.0.0:11021->21/tcp, 0.0.0.0:65000->65000/tcp, 0.0.0.0:65001->65001/tcp, 0.0.0.0:65002->65002/tcp, 0.0.0.0:65003->65003/tcp,
0.0.0.0:65004->65004/tcp
embulk-output-ftps_server /usr/sbin/run-vsftpd-with- ... Up 20/tcp, 0.0.0.0:990->21/tcp, 0.0.0.0:65005->65005/tcp, 0.0.0.0:65006->65006/tcp, 0.0.0.0:65007->65007/tcp, 0.0.0.0:65008->65008/tcp
$ ./gradlew test # -t to watch change of files and rebuild continuously
If you want to use other FTP server to test, configure the following environment variables.
FTP_TEST_HOST (default: localhost)
FTP_TEST_PORT (default: 11021)
FTP_TEST_SSL_PORT (default:990)
FTP_TEST_USER (default: scott)
FTP_TEST_PASSWORD (default: tigger)
FTP_TEST_SSL_TRUSTED_CA_CERT_FILE
FTP_TEST_SSL_TRUSTED_CA_CERT_DATA
If you’re using Mac OS X El Capitan and GUI Applications(IDE), like as follows.
$ vi ~/Library/LaunchAgents/environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>
launchctl setenv FTP_TEST_HOST ftp.example.com
launchctl setenv FTP_TEST_USER username
launchctl setenv FTP_TEST_PASSWORD password
launchctl setenv FTP_TEST_SSL_TRUSTED_CA_CERT_FILE /path/to/cert.pem
launchctl setenv FTP_TEST_SSL_TRUSTED_CA_CERT_DATA "-----BEGIN CERTIFICATE-----
ABCDEFG...
EFGHIJKL...
-----END CERTIFICATE-----"
</string>
</array>
<key>RunAtLoad</key>
<true></true>
</dict>
</plist>
$ launchctl load ~/Library/LaunchAgents/environment.plist
$ launchctl getenv FTP_TEST_HOST //try to get value.
Then start your applications.
This program is forked from embulk-input-ftp and originally written by @frsyuki, modified by @sakama.