Files, SFTP and downloads

Many systems still talk in files: a supplier's price list, a warehouse's stock file, an accountant's export. Three steps and one page handle them.

Step What it does
File transfer (SFTP / FTP) Reaches a server over SFTP, FTP or FTPS: list a folder, download, upload, delete or move a file
Download file Downloads a file from an https link into Files
Files Your store's files in this app: read a text file, write one, delete or list

Files is also a page in the app menu. It lists what your workflows stored, lets you upload and download files by hand, and shows your usage against the plan.

File keys

A file in Files is named by a file key, a path of your choice such as imports/stock.csv. Letters, digits, spaces and . _ - / are allowed, without .. and without a leading /. A file with the same key is replaced.

Steps hand files to each other by key: a download stores imports/prices.csv, the next step reads it, an email attaches it.

File transfer (SFTP / FTP)

  1. Choose the Protocol: SFTP, FTP (not encrypted) or FTPS (FTP over TLS).
  2. Enter Host, Port (empty means 22 for SFTP and 21 for FTP and FTPS; port 990 uses implicit TLS) and Username.
  3. Password: never type it here. Save it under Secrets and write {{ secrets.SFTP_PASSWORD }}. For SFTP you can use a Private key (a secret that holds the PEM key) with an optional Passphrase of the key, instead of or as well as a password.
  4. Optional for SFTP: Host key fingerprint, the server's SHA-256 fingerprint as ssh-keygen -lf prints it. When set, a server with another key is refused.
  5. Choose What to do:
Choice Fields
List a folder Folder, optional File name pattern such as *.csv. Up to 1,000 entries
Download a file File on the server, and Where the file goes: Into Files under a File key, or As text into this step's result (up to 256 KB)
Upload a file Path on the server, and What to upload: A file from Files or Text written here. A file that is already there is replaced. The folder must exist
Delete a file File on the server
Move or rename a file File on the server and New path

A workflow whose login is written into the step as plain text cannot be turned on. It must read a secret. See Secrets.

To handle every file of a folder, list it, then use the list in a Repeat for each and read each file as loop.item.path. The template Collect new files from your SFTP server and archive them there does that.

Download file

  1. Link: https only, and a public address. Up to 3 redirects are followed.
  2. File key: where the file goes in Files.
  3. Optional Headers, for example an Authorization header from a secret. Headers are sent to the host of the link only, never to a host it redirects to.

A file larger than your plan allows fails the step. It is never cut.

Files step

Choice Notes
Read a text file Text files up to 256 KB. The text is in the step's result
Write a file Content is text. One variable that holds an object or a list is stored as JSON. Content type is optional: empty means by the key's ending (.csv, .json, .xml, .txt), else text/plain
Delete a file
List files File keys that start with narrows the list. Up to 1,000 files: keys, sizes and types

Working with a file's content

Text up to 256 KB can be read into a step's result and worked on: a Liquid script step splits a CSV into lines, a Run function step parses it in JavaScript (it receives the text through input.steps). Larger files move between a server, a link and Files without passing through a step's result.

Limits by plan

Plan Files in total Largest file
Free 100 MB 5 MB
Starter 1 GB 10 MB
Grow 5 GB 25 MB
Unlimited 50 GB 50 MB

In tests

In a preview, listing and downloading from a server run for real. An upload, a delete, a move and a write to Files are only previewed. Download file downloads and checks the file, but does not store it.

When it fails

A server that cannot be reached, a timeout or a broken connection is tried again automatically. Listing, downloading and uploading can safely run twice; a delete or a move is only repeated when the server was never reached. A wrong login or a missing file fails the step at once. See Automatic retries.

Send a file by email

The Send email step attaches a file from Files by its key, up to 10 MB per email. See Send email and email senders and Recipe: email a daily file from SFTP.

Templates

The category Files and SFTP has complete workflows: drop every paid order as a CSV file on your SFTP server, set stock from a daily CSV file, update prices from a supplier's price list behind a link, copy a file from a link to your SFTP server.