SFTP Component
Read, write, move and delete files on an SFTP server
Component key: sftp
Description
The SFTP (SSH File Transfer Protocol) component lets you upload, download, move and delete files on an SFTP server.
A common integration pattern involves listing files in a file store, and performing a series of actions on the array of files that are returned. See our looping over files quickstart for information about how to create a loop over an array of files.
Connections
Basic Username/Password
The basic auth connection is used to connect to SFTP servers that support username / password login. Consult your SFTP server administrator to determine which login method the server supports.
On-prem enabled: this connection can be configured to connect to an on-prem resource on a private network. Learn more.
Input | Default | Notes | Example |
---|---|---|---|
Enable Unsecure Ciphers boolean enableUnsecureCiphers | false | If true, CBC ciphers will be added to the connection. | |
Host string / Required host | The address of the SFTP server. This should be either an IP address or hostname. | sftp.prismatic.io | |
Password password / Required password | p@s$W0Rd | ||
Port string / Required port | 22 | The port of the SFTP server. | 2222 |
Timeout string timeout | 3000 | How long the client will await a request. | 4000 |
Username string / Required username | john.doe |
Private Key
The private key connection allows you to access an SFTP server via SSH public/private key authentication. You will need to generate a public/private key pair, and ensure that your public key is stored on the SFTP server that you are connecting to. Then, you can authenticate with the SFTP server using a username and corresponding private key.
On-prem enabled: this connection can be configured to connect to an on-prem resource on a private network. Learn more.
Input | Default | Notes | Example |
---|---|---|---|
Enable CBC Ciphers boolean enableUnsecureCiphers | false | If true, CBC ciphers will be added to the connection. | |
Host string / Required host | The address of the SFTP server. This should be either an IP address or hostname. | sftp.prismatic.io | |
Key Passphrase password passphrase | Passphrase for the private key. Leave blank if none. | p@s$PHr@$3 | |
Password password password | Though uncommon, some SFTP servers that use private keys may also require a password. Leave blank if none. | p@s$W0Rd | |
Port string / Required port | 22 | The port of the SFTP server. | 2222 |
Private Key text / Required privateKey | SSH private key | -----BEGIN OPENSSH PRIVATE KEY----- abc123... | |
Timeout string timeout | 3000 | How long the client will await a request. | 4000 |
Username string / Required username | john.doe |
Actions
Create Directory
Create a new directory. If the recursive flag is set to true, the method will create any directories in the path which do not already exist. | key: createDirectory
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required path | Path of directory on an SFTP server to list files of | /path/to/directory/ | |
Recursive boolean recursive | true | If true, create any missing directories in the path as well |
Example Payload for Create Directory
{
"data": "/path/to/new/directory/"
}
Delete File
Delete a file from a SFTP server | key: deleteFile
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required path | Path of file to delete | /path/to/file.txt |
Fast Get
Read a file from SFTP | key: fastGet
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required inputPath | Path of file on SFTP server to read data from | /path/to/file.txt | |
Always Return Buffer boolean / Required returnBuffer | false | Always treat the file as a binary file with content type 'application/octet-stream', even if it is a text file. This is helpful if you are processing non-UTF-8 text files, as the runner assumes text files are UTF-8. |
Example Payload for Fast Get
{
"data": "Sample file contents",
"contentType": "text/plain"
}
List Directory
List files in a directory on an SFTP server | key: listDirectory
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required path | Path of directory on an SFTP server to list files of | /path/to/directory/ | |
Pattern string pattern | * | Glob-style string for listing specific files | *.txt |
Example Payload for List Directory
{
"data": [
"file.txt",
"example.txt"
]
}
Move File
Move a file on an SFTP server | key: moveFile
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Destination Path string / Required destinationPath | Path of file to move | /my/destination/path.txt | |
Source Path string / Required sourcePath | Path of file to move | /my/starting/path.txt |
Read File
Read a file from SFTP | key: readFile
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required inputPath | Path of file on SFTP server to read data from | /path/to/file.txt | |
Always Return Buffer boolean / Required returnBuffer | false | Always treat the file as a binary file with content type 'application/octet-stream', even if it is a text file. This is helpful if you are processing non-UTF-8 text files, as the runner assumes text files are UTF-8. |
Example Payload for Read File
{
"data": "Sample file contents",
"contentType": "text/plain"
}
Stat File
Pull statistics about a file | key: statFile
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required inputPath | Path of file on SFTP server to read data from | /path/to/file.txt |
Example Payload for Stat File
{
"data": {
"mode": 33279,
"uid": 1000,
"gid": 985,
"size": 5,
"accessTime": 1566868566000,
"modifyTime": 1566868566000,
"isDirectory": false,
"isFile": true,
"isBlockDevice": false,
"isCharacterDevice": false,
"isSymbolicLink": false,
"isFIFO": false,
"isSocket": false
}
}
Write File
Write a file to SFTP | key: writeFile
Input | Default | Notes | Example |
---|---|---|---|
Connection connection / Required connection | |||
Data text / Required data | Text to write into the file | ||
Show Debug Output boolean / Required debug | false | Show additional debug output in logs. Note: SFTP is very verbose - expect hundreds of debug lines when this is enabled. | |
Path string / Required outputPath | Path on SFTP server to write file | /we/love/commas.csv |
Example Payload for Write File
{
"data": "Uploaded data stream to /upload/path/to/file.txt"
}