Operator FTPPutFile

IBMStreams com.ibm.streamsx.inet Toolkit > com.ibm.streamsx.inet 3.4.0 > com.ibm.streamsx.inet.ftp > FTPPutFile

The FTPPutFile operator can put a local file on a remote host by using FTP, FTPS, or SFTP protocols. You can optionally rename the file after you complete the transfer.

The FTPPutFile operator must not be used inside a consistent region!

Summary

Ports
This operator has 2 input ports and 2 output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 17 parameters.

Required: host, localFilename, path, protocol, username

Optional: connectionCloseMode, connectionTimeout, curlVerbose, filename, password, renameTo, sendStatisticsOnError, skipPASVIp, transferTimeout, useEPRT, useEPSV, usePORT

Metrics
This operator does not report any metrics.

Properties

Implementation
C++
Threading
Always - Operator always provides a single threaded execution context.

Input Ports

Ports (0)

This input port triggers a file transfer. Typically the requested filenames are received from stream attributes.

Properties

Ports (1)

This optional input port may be used to set/change the username and password.

Properties

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Output Functions
GetStatistics
boolean Success()

Get the command success indication.

rstring Url()

This function returns a string with the url including schema of the transferred file.

uint64 FileSize()

This function returns the file size.

uint32 NoTransfers()

Deprecated: This function returns the number of completed ftp transfers. Use function TransferCount() instead.

uint32 TransferCount()

This function returns the number of completed ftp transfers.

uint32 NoTransferFailures()

Deprecated: This function returns the number of failed ftp transfers. Use function TransferFailureCount() instead.

uint32 TransferFailureCount()

This function returns the number of failed ftp transfers.

uint64 NoBytesTransferred()

Deprecated: This function returns the number of bytes transferred in successfully completed transfers. Use function BytesTransferred() instead.

uint64 BytesTransferred()

This function returns the number of bytes transferred in successfully completed transfers.

float64 TransferSpeed()

This function returns the transfer speed in byte per second of the last transfer / valid after file end.

<any T> T AsIs(T)

Return the argument unchanged.

GetError
int32 Error()

Deprecated: Get the error number. Use function ErrorCode() instead.

int32 ErrorCode()

Get the error number

rstring ErrorText()

Get the error description

rstring Url()

This function returns a string with the url including schema of the transferred file.

uint32 NoTransfers()

Deprecated: This function returns the number of completed ftp transfers. Use function TransferCount() instead.

uint32 TransferCount()

This function returns the number of completed ftp transfers.

uint32 NoTransferFailures()

Deprecated: This function returns the number of failed ftp transfers. Use function TransferFailureCount() instead.

uint32 TransferFailureCount()

This function returns the number of failed ftp transfers.

uint64 NoBytesTransferred()

Deprecated: This function returns the number of bytes transferred in successfully completed transfers. Use function BytesTransferred() instead.

uint64 BytesTransferred()

This function returns the number of bytes transferred in successfully completed transfers.

<any T> T AsIs(T)

Return the argument unchanged.

Ports (0)

The statistics stream with the statistics of the performed operation. The GetStatistics output functions must be applied to this port.

Properties

Ports (1)

The optional error stream with the diagnostics information. The GetError output functions may be applied to this port. If no output assignment is applied, the output stream must have a single attribute of type rstring.

Properties

Parameters

This operator supports 17 parameters.

Required: host, localFilename, path, protocol, username

Optional: connectionCloseMode, connectionTimeout, curlVerbose, filename, password, renameTo, sendStatisticsOnError, skipPASVIp, transferTimeout, useEPRT, useEPSV, usePORT

connectionCloseMode

This optionally parameter controls when the closing of connection after transfer. The parameter takes one value of type ConnectionCloseMode. Default value is never.

Properties

connectionTimeout

This is the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to switch to the default built-in connection timeout - 120 seconds. See also the transferTimeout parameter.

Properties

curlVerbose

Verbose mode for curl lib. Default value is false. The curl information are sent stderr.

Properties

filename

The filename part of the file/directory if the hostPath does not contain a filename part.

Properties

host

Hostname or IP address of the remote host in form hostname[:port].

Properties

localFilename

The name of the file to be transferred in the local file system. If relative, the path is relative to the data directory.

Properties

password

The password for the ftp user. If the operator has two input ports and this parameter is an attribute parameter it must be supplied from the second input port.

Properties

path

The path of the remote fie/directory. The path may contain an filename part. If the filename part is omitted the parameter must end with a '/'. In case of ftp protocols the path is relative to the home directory of the user and may depend on the server configuration. In case of ftp protocol an absolute path must start with '//'. In case of sftp the path is an absolute path. A path relative to users home directory may be entered in the form '~/'.

Properties

protocol

Protocol and encryption properties of the connection. This parameter takes one value of type Protocol

Properties

renameTo

The rename-to name. A file is renamed if this parameter is there and is non empty.

Properties

sendStatisticsOnError

If set to true, the operator sends out a statistics tuple on port 0 when the put-operation fails.

Properties

skipPASVIp

If set to true, it instructs libcurl to not use the IP address the server suggests in its 227-response to libcurl's PASV command when libcurl connects the data connection. Instead libcurl will re-use the same IP address it already uses for the control connection. But it will use the port number from the 227-response.

Properties

transferTimeout

This is the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. Default timeout is 0 (zero) which means it never times out.

Properties

useEPRT

If the value is true, it tells curl to use the EPRT (and LPRT) command when doing active FTP downloads (which is enabled by ftpPORT) default true. Using EPRT means that it will first attempt to use EPRT and then LPRT before using PORT, but if you pass false to this option, it will not try using EPRT or LPRT, only plain PORT. If the server is an IPv6 host, this option will have no effect as of 7.12.3.

Properties

useEPSV

If the value is true, it tells curl to use the EPSV command when doing passive FTP downloads (default true) Using EPSV means that it will first attempt to use EPSV before using PASV, but if you pass false to this option, it will not try using EPSV, only plain PASV If the server is an IPv6 host, this option will have no effect.

Properties

usePORT

It will be used to get the IP address to use for the FTP PORT instruction. The PORT instruction tells the remote server to connect to our specified IP address. The string may be a plain IP address, a host name, a network interface name or just a '-' symbol to let the library use your system's default IP address. Default FTP operations are passive, and thus won't use PORT. The address can be followed by a ':' to specify a port, optionally followed by a '-' to specify a port range. If the port specified is 0, the operating system will pick a free port. If a range is provided and all ports in the range are not available, libcurl will report CURLE_FTP_PORT_FAILED for the handle. Invalid port/range settings are ignored. IPv6 addresses followed by a port or portrange have to be in brackets. IPv6 addresses without port/range specifier can be in brackets. (added in 7.19.5)

Examples with specified ports:

eth0:0 192.168.1.2:32000-33000 curl.se:32123 [::1]:1234-4567

You disable PORT again and go back to using the passive version by setting this option to an empty string.

Properties

username

The ftp username. If the operator has two input ports and this parameter is an attribute parameter it must be supplied from the second input port.

Properties

Code Templates

FTPPutFile

stream<rstring path, rstring file, uint64 size, rstring url, boolean success> ${ResultStream} as OUT = FTPPutFile(${FilenameStream}) {
	param
		protocol : ftp;
		host : "${host}";
		path : "/${path}/";
		username : "${username}";
		password : "${password}";
		localFilename : path;
		filename : "file.tmp";
		renameTo : file;
		sendStatisticsOnError : true;
	output OUT :
		size = FileSize(),
		url = Url(),
		success = Success();
}
      

Libraries

curl lib
Library Name: curl
FTP wrapper lib
Library Name: inettoolkit
Library Path: ../../impl/lib
Include Path: ../../impl/include