Skip to main content

workerd-ftp

A powerful FTP client designed specifically for Cloudflare Workers, leveraging the TCP Sockets API to enable FTP operations in serverless environments.

Why workerd-ftp?

Cloudflare Workers provide a powerful edge computing platform, but traditional FTP clients don’t work in this environment. workerd-ftp bridges this gap by using Cloudflare’s TCP Sockets API to provide full FTP functionality in your Workers.

Serverless-first

Built specifically for Cloudflare Workers runtime with TCP Sockets support

Secure transfers

FTPS support via TLS encryption for secure file operations

Stream-based

Download and upload files using modern ReadableStream and WritableStream interfaces

Full-featured

Complete FTP operations including list, upload, download, rename, and delete

Key features

Passive mode only

workerd-ftp operates in passive mode, as Cloudflare Workers only support outgoing TCP connections. This is the standard mode for most modern FTP operations.

FTPS via TLS

Secure your file transfers with built-in TLS support. Enable encryption by setting the secure option to true when connecting.

Stream-based file operations

Upload and download files efficiently using the Web Streams API:
  • Downloads: Get files as ReadableStream<Uint8Array> for processing chunks as they arrive
  • Uploads: Use WritableStream<Uint8Array> to send data without loading entire files into memory

Complete file management

Perform all essential FTP operations:
  • List directory contents with detailed file information
  • Create and remove directories
  • Upload and download files
  • Rename and delete files and directories
  • Get file metadata (size, modification time)
  • Navigate directory structures

Use cases

Backup automation

Automatically back up files to FTP servers from your Workers

File synchronization

Sync files between FTP servers and cloud storage

Content delivery

Upload generated content or media files to FTP servers

Legacy integration

Connect modern edge applications with legacy FTP-based systems

Requirements

Your Cloudflare Worker must have TCP Sockets enabled in your account. This feature requires a Workers Paid plan.
To use workerd-ftp, you need:
  • A Cloudflare Workers Paid plan with TCP Sockets enabled
  • Node.js 18+ for development
  • An FTP server to connect to

Quick example

Here’s a simple example showing how to connect and upload a file:
import { FTPClient } from "workerd-ftp";

const ftp = new FTPClient('ftp.example.com', {
  port: 21,
  user: 'username',
  pass: 'password',
  secure: false
});

await ftp.connect();

// Upload a file
await ftp.upload('hello.txt', new TextEncoder().encode('Hello, World!'));

// Download a file
const data = await ftp.download('hello.txt');
const text = new TextDecoder().decode(data);

await ftp.close();

Next steps

Installation

Install workerd-ftp in your project

Quick start

Get started with your first FTP connection

Build docs developers (and LLMs) love