workerd-ftp
v0.1.3
Published
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![bundle][bundle-src]][bundle-href] [![Codecov][codecov-src]][codecov-href]
Downloads
1,439
Readme
📁 Cloudflare Worker FTP Client
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.