ConnectorTypeFTP
class connector_types.connector_type_ftp.ConnectorTypeFTP
Connect to a FTP server.
This connector type uses the FTP protocol to list folder contents, to transfer files between Cloudomation and the remote host, to rename or or delete files or directories.
The FTP protocol should not be confused with SFTP. While similar in names, FTP and SFTP use different protocols and offer different ways of transferring files. If you want to use the SFTP protocol, refer to ConnectorTypeSCP
For more on the differences between FTP and SFTP refer to Difference between FTP and SFTP
Currently supported connection methods:
- plain FTP: not encrypted, insecure
- implicit FTPS: FTP over TLS
Currently unsupported connection methods:
- explicit FTPS: plain FTP upgrading to TLS using the AUTH command
Inputs
Name | Type | Default | Description |
---|---|---|---|
action | String | copy | The action to perform. Supported actions: copy , list , stats , remove , or rename . |
check_hostname | bool | True | If set, the hostname of the FTP server is checked against the server_ca certificate. |
client_cert | str | None | A client certificate used to authenticate the SSL transport. |
client_key | str | None | The key of the client certificate used to authenticate the SSL transport. |
connect_timeout | int | 60 | Timeout for connection establishment. |
dst | String | None | The path of the destination file. Use the format "cloudomation:[path]" to copy a file to cloudomation. Must be set for action copy or rename . |
encoding | str | utf-8 | Encoding used to convert binary responses to strings. |
hostname | String | The remote host name to connect to | |
password | String | The password to use to authenticate | |
path | str | None | The path to use. Must be set for action list , stats and remove . |
port | Number | 21 | The port number to connect to |
recursive | bool | False | If listing should be performed recursively. Only used for action list . |
server_ca | str | None | The CA certificate of the server. To be used for self-signed certificates. |
socket_timeout | int | 60 | Timeout for read operations. |
src | String | None | The path of the source file to copy. Use the format "cloudomation:[path]" to copy a file from cloudomation. Must be set for action copy or rename . |
username | String | The user name to use |
Outputs
Name | Type | Default | Description |
---|---|---|---|
listing | dict | {} | The contents of the directory. Only set when using the list action. |
log | list | [] | |
stats | dict | {} | A dictionary containing information about the path.. Only set when using the stats action. |
Constants
input_list = ['action', 'check_hostname', 'client_cert', 'client_key', 'connect_timeout', 'dst', 'encoding', 'hostname', 'password', 'path', 'port', 'recursive', 'server_ca', 'socket_timeout', 'src', 'username'] output_list = ['listing', 'log', 'stats'] ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca'] version = 1Methods
execute
log
one_of_inputs
run
Example
Download a file from a FTP server to Cloudomation.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='FTP',
name='download a file',
hostname='my-ftp-host',
username='myself',
password='***',
action='copy',
src='path/to/file.txt',
dst='cloudomation:file.txt',
)
return this.success('all done')
More
File Upload
Upload a file from Cloudomation to a FTP server.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='FTP',
name='upload a file',
hostname='my-ftp-host',
username='myself',
password='***',
action='copy',
src='cloudomation:file.txt',
dst='path/to/file.txt',
)
return this.success('all done')
Directory listing
List the content of a directory.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
listing = this.connect(
connector_type='FTP',
name='list a directory',
hostname='my-ftp-host',
username='myself',
password='***',
action='list',
path='path/to/list',
).get('output_value')['listing']
return this.success('all done')
Get file or directory information
Read information about a file or a directory on the server.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
stats = this.connect(
connector_type='FTP',
name='get information',
hostname='my-ftp-host',
username='myself',
password='***',
action='stats',
path='path/to/file.txt',
).get('output_value')['stats']
return this.success('all done')
Remove a file or a directory
Remove a file or a directory from the server.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='FTP',
name='remove a file',
hostname='my-ftp-host',
username='myself',
password='***',
action='remove',
path='path/to/file.txt',
)
return this.success('all done')
Rename a file or a directory
Rename a file or a directory on the server.
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
this.connect(
connector_type='FTP',
name='rename a file',
hostname='my-ftp-host',
username='myself',
password='***',
action='rename',
src='path/to/file.txt',
dst='new/path/renamed.csv',
)
return this.success('all done')