Skip to content

3.4 FTP download uploading of files

MarkVanDijkHG edited this page Apr 16, 2024 · 3 revisions

Downloading or uploading files via FTPs or sFTP

The Ftp action type describe the FTP actions to be performed and which protocol to use. See Actions for more information about the default fields. For developers: the FTPs are loaded into the FtpModel.

The properties of an FTP action

Property name Mandatory Default value Explanation
Type no Ftps The protocol/types of FTP connection to use. Use Ftps for an FTPS connection and use Sftp for an SFTP connection.
Action no Download The action to be performed, the options are;
Upload: upload files.
Download: download files.
FilesInDirectory: retrieve all the names of files in a directory.
Delete: performs a delete action.
Move: moves a file on the server.
Rename: other name for the move action.
EncryptionMode no Auto The encryption mode to be used with an FTPS connection. The options are;
Auto: Automatic encryption.
None: No encryption.
Implicit: Implicit encryption.
Explicit: Explicit encrypt.
Host yes Null The URL or IP address of the server to connect to.
Port yes Null The server port number to connect to.
User yes Null The username with which to log in.
Password yes Null The password with which to log in.
From no Null The location of the file or folder* to which the action applies. When left empty in an upload, the body will be used. Can use a result set for dynamic path building.

* Folders are handled correctly only if AllFilesInFolder is set to true.
Body no Null A body element used to upload a file to the server.
To no Null The location of the file or folder* being written to. Can be a result set used for dynamic path building.

For "FilesInDirectory" and "Delete" actions, this value is not used and does not need to be provided.

* Folders are handled correctly only if "AllFilesInFolder" is set to true.
AllFilesInFolder no false When true, the action is performed on all files in the folder.
DeleteFileAfterAction no false Deletes the file from the server or local system after the action is complete. Runs only if all files within the action were successful.
UsePassive no true For FTPS whether the connection should be passive.
SshPrivateKeyPath no Null Bij SFTP het pad naar het bestand met de private key.
SshPrivateKeyPassphrase no Null With SFTP, the passphrase for the private key.
SingleAction no true Performs the action 1 time on a file or folder. If it is not a single action it must reference an array in the result set, for each item in that list before the action is executed.

The result set

Property name Explanation
FromPath The path from where the action takes place.
ToPath The path to where the action takes place.
Action The action type performed.
Success Whether the action was successful or not.
FilesInDirectory With the "FilesInDirectory" action, an array containing all the names of the files contained in the specified directory.
FilesInDirectoryCount For the "FilesInDirectory" action, the number of files contained in the specified directory.

FTPresultsset

Examples

FTPS upload

An FTP that uploads a file to an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Upload</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>C:\temp\file.txt</From>
	<To>/ftps/file.txt</To>
</Ftp>

SFTP upload

An FTP that uploads a file a an SFTP server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Sftp</Type>
	<Action>Upload</Action>
	<Host>192.168.120.48</Host>
	<Port>2222</Port>
	<User></User>
	<Password></Password>
	<From>C:\temp\file.txt</From>
	<To>/ftps/file.txt</To>
</Ftp>

Upload body

An FTP that uses a body action to generate a file and uploads it to an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Upload</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<To>/ftps/body-file.txt</To>
	<Body>
		<ContentType>text/plain</ContentType>
		<BodyParts>
			<BodyPart>
				<Text>Test file.</Text>
			</BodyPart>
		</BodyParts>
	</Body>
</Ftp>

Upload all files in folder

An FTP that uploads all files in a folder to an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Upload</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>C:\WTS configurations\upload</From>
	<To>/ftps/</To>
	<AllFilesInFolder>true</AllFilesInFolder>
</Ftp>

Download

An FTP that downloads a file from an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Download</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/ftps/file.txt</From>
	<To>C:\temp\file.txt</To>
</Ftp>

Download all files in folder

An FTP that downloads all files in a folder from an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Download</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/ftps/</From>
	<To>C:\WTS configurations\download</To>
	<AllFilesInFolder>true</AllFilesInFolder>
</Ftp>

Get the names of all files in a folder

An FTP that retrieves all the names of files in a folder on an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>FilesInDirectory</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/ftps/</From>
</Ftp>

Delete files from an FTPS server

An FTP that deletes a file on an FTPS server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Delete</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/ftps/file.txt</From>
</Ftp>

Delete files after download

An FTP that downloads all files in a folder from an FTPS server and then deletes the files on the server.

<Ftp>
	<TimeId>1</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Download</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/ftps/</From>
	<To>C:\WTS configurations\download</To>
	<AllFilesInFolder>true</AllFilesInFolder>
	<DeleteFileAfterAction>true</DeleteFileAfterAction>
</Ftp>

Move / Rename a file on the server

An FTP that uses the rename action on am FTPS server and an FTP that uses the move action on an SFTP server.

<Ftp>
	<TimeId>6</TimeId>
	<Order>1</Order>
	<Type>Ftps</Type>
	<Action>Rename</Action>
	<Host>localhost</Host>
	<Port>21</Port>
	<User></User>
	<Password></Password>
	<From>/old_file.txt</From>
	<To>/new_file.txt</To>
</Ftp>

<Ftp>
	<TimeId>6</TimeId>
	<Order>2</Order>
	<Type>Sftp</Type>
	<Action>Move</Action>
	<Host>localhost</Host>
	<Port>2222</Port>
	<User></User>
	<Password></Password>
	<From>/old_file.txt</From>
	<To>/new_file.txt</To>
</Ftp>