Skip to content

Conversation

@marshallswain
Copy link
Member

This PR adds native FormData and file upload support to the Feathers HTTP transport.

Changes

Client (packages/feathers/src/client/fetch.ts)

  • Auto-detects FormData in request body and skips JSON serialization
  • Lets the browser set the correct Content-Type header with multipart boundary

Server (packages/feathers/src/http/middleware.ts)

  • Added multipart/form-data parsing in bodyParser() using native request.formData()
  • Converts FormData to plain object (single values unwrapped, multiple values become arrays)

Test Fixture (packages/feathers/fixtures/index.ts)

  • Replaced @whatwg-node/server with a native Node.js adapter
  • Fixes a bug where duplicate FormData keys were being lost

Usage

// Client
const formData = new FormData()
formData.append('file', fileInput.files[0])
formData.append('description', 'My upload')

await app.service('uploads').create(formData)

// Server receives:
{
  file: File,
  description: 'My upload'
}

// Multiple values become arrays:
{
  files: [File, File, File]
}

Limitations

  • REST only - FormData is not supported over Socket.io
  • Buffered - Uses native request.formData() which buffers into memory. For large files, use presigned URLs to upload directly to cloud storage.

Breaking Changes

None. This is additive functionality.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 19, 2025

Deploying feathers-dove with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc5c4f5
Status: ✅  Deploy successful!
Preview URL: https://17fa6525.feathers.pages.dev
Branch Preview URL: https://v6-form-data.feathers.pages.dev

View logs

@marshallswain marshallswain changed the base branch from dove to v6 December 19, 2025 05:02
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 19, 2025

Deploying feathers-eagle with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc5c4f5
Status: ✅  Deploy successful!
Preview URL: https://2a0e091a.feathers-a8l.pages.dev
Branch Preview URL: https://v6-form-data.feathers-a8l.pages.dev

View logs

- Auto-detect FormData in fetch client and skip JSON serialization
- Parse multipart/form-data in server bodyParser middleware
- Convert FormData to plain object (single values unwrapped, multiple become arrays)
- Replace @whatwg-node/server with native Node.js adapter for proper FormData handling
- Add tests for FormData handling in client and server
- Update REST client docs with FormData and file upload section
@daffl daffl merged commit 8476bf2 into v6 Dec 19, 2025
6 checks passed
@daffl daffl deleted the v6-form-data branch December 19, 2025 22:51
@daffl
Copy link
Member

daffl commented Dec 19, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants