Skip to main content
Version: 6 - Palatschinke

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.

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
  • SFTP: SSH file transfer protocol

Inputs

NameTypeDefaultDescription
actionStringcopyThe action to perform. Supported actions: copy, list, stats, remove, or rename.
check_hostnameboolTrueIf set, the hostname of the FTP server is checked against the server_ca certificate.
client_certstrNoneA client certificate used to authenticate the SSL transport.
client_keystrNoneThe key of the client certificate used to authenticate the SSL transport.
connect_timeoutint60Timeout for connection establishment.
dstStringNoneThe path of the destination file. Use the format "cloudomation:[path]" to copy a file to cloudomation. Must be set for action copy or rename.
encodingstrutf-8Encoding used to convert binary responses to strings.
hostnameStringThe remote host name to connect to
passwordStringThe password to use to authenticate
pathstrNoneThe path to use. Must be set for action list, stats and remove.
portNumber21The port number to connect to
recursiveboolFalseIf listing should be performed recursively. Only used for action list.
server_castrNoneThe CA certificate of the server. To be used for self-signed certificates.
socket_timeoutint60Timeout for read operations.
srcStringNoneThe 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.
usernameStringThe user name to use

Outputs

NameTypeDefaultDescription
execution_idintThe ID of the connection execution
listingdict{}The contents of the directory. Only set when using the list action.
loglist[]
messagestrThe ended message for the connection. If the connection ended with an error, the message will contain information about what went wrong
statsdict{}A dictionary containing information about the path.. Only set when using the stats action.
statusstrThe ended status for the connection. Either "success" or "error".

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 = 1

Methods

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')