Omniscope Custom Blocks › Inputs/SFTP-Downloader

SFTP Downloader

Downloads the files in a folder on an SFTP server to the Omniscope server and lists them, ready for an Append files block to load.

Inputs Python

Open the demo in Omniscope Download demo.ioz Sample data: placeholder.csv Source on GitHub

Omniscope custom block · Inputs

Files dropped on an SFTP server every night? Fetch the ones you need on each run, check you are talking to the right server, and hand them to Append files.

Python · paramiko, pandas · paramiko installed on first run if missing

The problem it solves

Daily sales from a franchise partner, statements from a bank, payroll from a bureau: plenty of data still arrives as files on an SFTP server. Someone downloads them with a desktop client and copies them to where the reporting can see them, or the reports wait until they do.

This block signs in to the server, downloads the files that match from one folder, and lists them with their paths so the rest of the workflow can load them.

How it works

What goes in

Nothing from the workflow: the block reads from the SFTP server. The demo uses an invented folder of a fictional garden supplies wholesaler: three daily sales files, a store list, a README and an archive folder. sample-data/placeholder.csv holds the block's output for it.

The options

Option Demo setting What it does
User name reports The account to sign in with.
Password (a password) The password, or a private key's passphrase.
Private key file (empty) A private key file on the Omniscope server, instead of or as well as the password.
Host name sftp.example.com The SFTP server.
Port 22 Usually 22.
Host key SHA256:... The server's fingerprint; a different key stops the block. Empty: any key is accepted.
Folder on the SFTP server /outgoing The folder to download from.
Files to download csv Extensions or patterns, comma-separated, not case-sensitive.
Download to folder /data/omniscope/downloads/sftp Where the files go on the Omniscope server. Empty: the block's working folder.

What comes out

Files

File path File name Size (bytes) Modified
/data/omniscope/downloads/sftp/daily-sales-2025-03-03.csv daily-sales-2025-03-03.csv 182 2025-03-03 02:00:00
/data/omniscope/downloads/sftp/daily-sales-2025-03-04.csv daily-sales-2025-03-04.csv 182 2025-03-04 02:00:00
/data/omniscope/downloads/sftp/daily-sales-2025-03-05.csv daily-sales-2025-03-05.csv 182 2025-03-05 02:00:00
/data/omniscope/downloads/sftp/stores.CSV stores.CSV 100 2025-01-10 09:30:00

4 records. The README.txt and the archive folder are not downloaded.

Where it pays off

Retail and franchises: Partner sales files

Load the nightly sales files that partners or franchisees drop on an SFTP server, into the same Report as your own sales.

Finance: Bank and payment statements

Fetch statement and settlement files from a bank's or payment provider's SFTP service for reconciliation.

HR and payroll: Bureau extracts

Pick up payroll and headcount extracts from a bureau, with the server's key checked each time.

Legacy systems: Scheduled exports

Collect the files an older system exports to an SFTP folder, instead of copying them by hand.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

SFTP Downloader → Append files (file paths from the upstream block: File path) → Field Organiser → Join (store list) → Report

Use Filter on Modified, before Append files, to load only the files of the last few days.

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder). It holds the SFTP Downloader with an example server (not run) and a File block with placeholder.csv, the list the block gives for the invented folder.
  2. The question: which files arrived, and when?
  3. Follow the File block into the rest of the workflow: 4 files, three of them daily sales.
  4. To use your own server: enter its details, user name and password or key, paste its fingerprint into Host key, run the block, and connect its output where the File block was, then on to an Append files block.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the placeholder data, the block, and a Validate data check on the output.

Language and libraries

Python, with paramiko (LGPL 2.1) and pandas (BSD 3-Clause).

pandas is part of Omniscope's Python environment. paramiko is listed in the block's dependencies, so Omniscope installs it with pip on first run if it is missing.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API and a stand-in for the SFTP connection (no server is contacted): the files listed and downloaded, extensions and patterns, sub-folders skipped, the host key as a fingerprint or a known_hosts line and a mismatching key, a refused sign-in, an unreachable server and a missing folder, a private key file, missing options, an empty result, the default download folder, and 3,000 files.

Reference

Options

NameTypeWhat it does
User nameTextThe account to sign in to the SFTP server with.
PasswordPasswordThe account's password, or the passphrase of the private key. Can be empty when a key without a passphrase is used.
Private key fileFileOptional: a private key file on the Omniscope server (OpenSSH format) to sign in with instead of, or as well as, the password.
Host nameTextThe SFTP server, such as sftp.example.com.
PortWhole numberUsually 22.
Host keyTextThe server's key fingerprint, such as SHA256:Kx3c..., or its known_hosts line. The block stops if the server offers a different key. Empty: any key is accepted.
Folder on the SFTP serverTextThe folder whose files to download, such as /outgoing/daily. Sub-folders are not entered.
Files to downloadTextExtensions or patterns, separated by commas: csv, xlsx or sales_*.csv (not case-sensitive). Empty: every file in the folder.
Download to folderTextA folder on the Omniscope server to save the files in (created if missing; files of the same name are replaced). Empty: the block's own working folder.

Outputs

OutputWhat it holds
FilesOne record per downloaded file: File path (on the Omniscope server), File name, Size (bytes) and Modified (on the SFTP server, UTC).