Skip to main content

SFTP

The SFTP connector reads, writes, lists and deletes files on an SFTP server. Mention it as @extfs_sftp. Each run can take the next new file as a pipeline item.

Connect​

The credential holds the login: Username, and a Password or a Private Key. A private key can be RSA, Ed25519 or ECDSA. When the key is protected by a passphrase, enter it in Private Key Passphrase. When both are filled in, Unstract Flow uses the key. Connectors, instances and credentials covers the rest of the setup.

SettingDefaultWhat it does
HostNone, requiredThe server's address.
Port22The SSH port.
Base Path/The folder that paths start from.
Include sub-foldersOffWhen on, a scan for new files also looks in the folders below the one the workflow scans.

What a step can do​

ActionWhat it does
claim_next_fileClaims the next available file for this run. claim_next_files claims several at once.
read_fileCopies a file into the run's files.
write_fileUploads a file from the run's files. If a file with that name is already there, the step fails, unless the step says to replace it.
delete_fileDeletes a file.
list_filesLists files in a folder. It returns one file unless the step asks for more, and by default only files no run has taken yet; a step can ask for every file instead. A listing of new files reads at most 5,000 files and sub-folders from the folder, counting the files that don't match the step's pattern. When it stops there short of the number asked for, it says more may exist; claim_next_files takes them. It also shows a file that is still being uploaded; only a claim waits for a file to stop changing.
mark_file_processedMarks a claimed file Success or Failed. mark_files_processed marks several at once.

Take the next new CSV from @extfs_sftp under outbound/. Load its rows into the shipments table in @database.

How runs read the files​

Unstract Flow reads the server only while a run is going; nothing watches it between runs. When a run claims a file, Flow takes a file it has already found in that folder, and in its sub-folders when Include sub-folders is on, for this connector instance, matching the step's pattern if it has one. A new instance has no record of earlier runs, so it processes every file already in the folder again; so does an imported workflow, even one imported into the same organization. When none is left, it scans the folder for new files, at most once every 30 seconds for each folder and pattern, shared by runs working in parallel. The scan looks in that folder only, unless the connector's Include sub-folders setting is on. The run copies the file into its own files at the same relative path, and a later step marks it Success or Failed. If a run ends with a file still in progress, the file is marked Failed once eight hours have passed since the claim; the check runs every 5 minutes. To free it sooner, select Release claims in the details of a run that ended Partial, Failed or Cancelled. Pipelines covers the states.

A file larger than 500 MB can't be copied into a run or uploaded, and a copy or an upload must finish within three minutes. Flow tells files apart by name, size and modification time, so a file that is changed or renamed counts as a new file. A claim takes a file only once it has gone a minute without changing, so a file still being uploaded waits until it's complete. An upload that stalls for more than a minute can still be taken half-written. Flow measures the minute by its own clock, so a server whose clock runs slow can have a file taken while it's still uploading. If your senders' uploads can stall, have them upload under another name and rename the file when it's complete, and claim with a pattern such as *.csv.