Developer December 20, 2024 8 min read TrueFTP Team

Automating File Transfers with TrueFTP

A practical guide to automating file transfer workflows over FTP with TLS, with code examples in Bash, Python, and Node.js, plus webhook-driven processing.

Manual uploads don't scale. Once files arrive on a schedule — nightly exports, partner drops, batch reports — you want them moving without a human in the loop. Because TrueFTP speaks standard FTP over explicit TLS, you can automate it with the tooling you already have. Here are three common patterns.

1. Shell scripts with curl

curl supports FTP with TLS out of the box, which makes it perfect for cron jobs:

#!/usr/bin/env bash
set -euo pipefail
 
HOST="ftp.trueftp.com"
PORT="2121"
USER="acme:reports"
PASS="${TRUEFTP_PASSWORD}"
 
# Upload last night's export
curl --ftp-ssl --fail \
  -T "/data/exports/$(date +%F).csv" \
  "ftp://${USER}:${PASS}@${HOST}:${PORT}/incoming/"

Schedule it with cron:

0 2 * * *  /opt/scripts/upload-export.sh >> /var/log/trueftp.log 2>&1

2. Python with ftplib

The standard library's ftplib includes FTP_TLS, so there are no dependencies to install:

import os
from ftplib import FTP_TLS
 
ftp = FTP_TLS()
ftp.connect("ftp.trueftp.com", 2121)
ftp.login("acme:reports", os.environ["TRUEFTP_PASSWORD"])
ftp.prot_p()  # encrypt the data channel
 
with open("report.csv", "rb") as f:
    ftp.storbinary("STOR incoming/report.csv", f)
 
ftp.quit()

3. Node.js with basic-ftp

In JavaScript, the basic-ftp package keeps things terse:

import { Client } from "basic-ftp"
 
const client = new Client()
await client.access({
  host: "ftp.trueftp.com",
  port: 2121,
  user: "acme:reports",
  password: process.env.TRUEFTP_PASSWORD,
  secure: true, // explicit TLS
})
 
await client.uploadFrom("report.csv", "incoming/report.csv")
client.close()

Trigger downstream work with webhooks

Polling a directory on a timer is wasteful. Instead, let TrueFTP tell you when a file lands. Configure a webhook and process files the moment they arrive:

// Express webhook receiver
app.post("/hooks/trueftp", (req, res) => {
  const { event, path, user } = req.body
  if (event === "file.uploaded" && path.startsWith("/incoming/")) {
    enqueueProcessing(path) // hand off to your pipeline
  }
  res.sendStatus(200)
})

Tips for reliable automation

  • Store secrets in env vars, never in the script. Rotate per-user credentials regularly.
  • Use a dedicated FTP user per integration so you can revoke one without affecting others.
  • Check exit codes (curl --fail, non-zero on error) and alert on failure.
  • Lean on version history — re-running a job won't silently destroy the previous file.

Next steps

Every example above works against a live TrueFTP account today. Start a free trial, create a scoped FTP user, and wire up your first automated transfer in a few minutes. For programmatic storage access, the Scale plan adds an S3-compatible API alongside FTP.

Try managed FTP for yourself

Spin up a free trial and connect your first FTP client in minutes.