All posts

Spooldoc 0.5.0: files to an SFTP server

An SFTP destination with a host key you check, the folder on the server listed in the job builder, and email and webhook runs that tell a new spooled file from an earlier one.

Spooldoc 0.5.0 is out. A job can now upload its files to a folder on an SFTP server: the invoices to the bank, the delivery notes to an EDI partner. Spooldoc trusts the server only after you compare its host key, and the job builder lists the folder on the server before the first run. Email and webhook runs no longer skip a new spooled file that has the job number of an earlier one. Nothing breaks: the upgrade is a pull and a restart.

What changed

SFTP destination. An SFTP destination uploads each file of a run to a folder on an SFTP server, over one connection. It signs in with a key Spooldoc makes, with your own key, or with a password. A key Spooldoc makes is Ed25519 by default, or RSA 4096 for a server that refuses Ed25519; the dialog shows the public key line to add to authorized_keys, and the private key never leaves Spooldoc. Spooldoc never creates the folder: a missing one fails the run before any file is written. Each file is written under a temporary name and renamed when it is whole, so a program that watches the folder sees whole files only. The server can be an IBM i, through its SSH server. SFTP has the details.

A host key you check. Spooldoc trusts exactly one host key per destination and never takes one on its own. Check connection prints each step as it goes: the host and port, the host key, the sign-in and the folders. A new destination stops at the host key, before it signs in, and shows its fingerprint as ssh-keygen -l prints it. Compare it with the server's own, then pick Trust this key. A changed host key fails every run with both fingerprints. The host key has the commands to compare them.

The New destination dialog with SFTP picked is filled in for sftp.example.com as MYUSER, with the public key line of the key Spooldoc made and the folder /in/invoices. The Connection box below lists each step of the check: reached the host on port 22, the trusted ED25519 host key with its fingerprint, signed in as MYUSER with the key, and both folders found.The New destination dialog with SFTP picked is filled in for sftp.example.com as MYUSER, with the public key line of the key Spooldoc made and the folder /in/invoices. The Connection box below lists each step of the check: reached the host on port 22, the trusted ED25519 host key with its fingerprint, signed in as MYUSER with the key, and both folders found.

The folder on the server, in the job builder. The destination step lists the folder on the server live, with the page group's files placed among the files already there. Each is tagged with what a run will do: New, Replaces the file from 14 Oct, Becomes invoice-260101-2.pdf, or Fails the run. With a test folder set on the destination, Upload test uploads one page group there now, and runs write there too, so the receiver never picks up a test. The folder view has the details.

The destination step of an invoice job uploads to SFTP. Beside the page group stepper, the test folder MYUSER@sftp.example.com:/test/in is listed with earlier invoices around invoice-260101.pdf, which Upload test has just uploaded, with its size and time. Below the listing, Upload test and the line Test: files go to /test/in.The destination step of an invoice job uploads to SFTP. Beside the page group stepper, the test folder MYUSER@sftp.example.com:/test/in is listed with earlier invoices around invoice-260101.pdf, which Upload test has just uploaded, with its size and time. Below the listing, Upload test and the line Test: files go to /test/in.

Every upload in the job log. A run lists each file with the path it got on the server, its size and its status. When one file cannot be written, the others are still uploaded. Then the run fails with "Uploaded 5 of 6 files to /in/invoices on sftp.example.com" and the first reason, and the spooled file is not held, moved or deleted. After you fix the cause, Retry uploads only the files not uploaded yet. Uploads has the statuses.

Already sent means the same spooled file. The IBM i reuses job numbers, so a new spooled file can have the same name, number and job as an earlier one. Email and webhook runs took it for the earlier one and skipped it as already sent. Now a document counts as sent only for the same creation time, pages and name, and SFTP uploads match the same way. A Retry that starts while another run is still delivering the same spooled file waits for it, so nothing goes out twice. A destination in test mode sends every document to the test address, URL or folder, also the ones sent for real before, so a template change can be checked on a spooled file that was delivered.

Email fixes. An address with a name, such as "Smith, John" <john@example.com>, is read as one address and sent with the name. SMTP keeps one connection for a run instead of signing in for every email, which mail providers limit. A full mailbox says so, with the address, instead of "too large". In test mode, the preview shows Cc and Bcc struck through, since a test goes only to the test address.

All changes are in the release notes.

Upgrading

Take a pg_dump, then pull ghcr.io/strom-capital/spooldoc:0.5.0 and start it. The server applies the new migrations. Nothing else needs you: jobs and destinations from 0.4 open and run as before. Emails and calls sent before the upgrade still count as sent, so a Retry right after it sends no second copy.

  • To upload to an SFTP server, Spooldoc needs to reach it, on port 22 by default.
  • Webhook receivers that drop repeats by webhook-id: the id of a document first sent after the upgrade also depends on the spooled file's creation time and pages. A Retry of a call sent before the upgrade keeps its old id.

Tell us

Questions go to Q&A, ideas to Ideas, bugs to the issues. We most want to hear about an SFTP server or a file transfer gateway that refuses Spooldoc's key, its temporary names or its renames. Replace real host, user, address and folder names before you paste it.

The 0.5.0 release is on GitHub, and so is the announcement. Every change is in the changelog.

All changes in 0.5.0 are in the changelog.