Skip to content

FTP Client for use inside Cloudflare Workers, using the Cloudflare Worker TCP Sockets API.

License

Notifications You must be signed in to change notification settings

Brand-Boosting-GmbH/workerd-ftp

Repository files navigation

📁 Cloudflare Worker FTP Client

npm version npm downloads bundle Codecov

FTP Client for use inside Cloudflare Workers, using the Cloudflare Worker TCP Sockets API.

This package relies heavily on the groundwork provided by nullobsi/ftpdeno.

  • ☁️ Passive mode (as Cloudflare only supports outgoing TCP connections)
  • 🔐 FTPS via TLS
  • 📥 Downloading/uploading via Readable and Writable interfaces
  • 📂 List files
  • 🛠️ Creating directories and files
  • ✏️ Renaming directories and files
  • 🗑️ Deleting directories and files

Read more about the TCP Socket connect() API in the Cloudflare Blog: https://blog.cloudflare.com/workers-tcp-socket-api-connect-databases

Usage

Install package:

# npm
npm install workerd-ftp

# yarn
yarn add workerd-ftp

# pnpm
pnpm install workerd-ftp

# bun
bun install workerd-ftp

Import:

import { FTPClient } from "workerd-ftp";

const ftp = new FTPClient('$SERVER$', {
  port: 21,
  user: '$USER$',
  pass: '$PASS$',
  secure: false
})
await ftp.connect()

// get currend working directory
const cwd = await ftp.cwd()

// upload file
await ftp.upload('test.txt', new TextEncoder().encode('hello world'))

// download file
const file = await ftp.download('test.txt')
const text = new TextDecoder().decode(file)

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.

About

FTP Client for use inside Cloudflare Workers, using the Cloudflare Worker TCP Sockets API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published