mjackson / remix-the-web

Open source tools for Remix (or any framework!)
MIT License
710 stars 14 forks source link

[form-data-parser] Accept FormData compatible data types from the upload handler #16

Open lennerd opened 1 month ago

lennerd commented 1 month ago

There is a minor roadblock in using the multipart-parser library, which seems solvable with a simple fix.

Our Setup

The Issue

The requestHandler function's upload handler currently only accepts File, null or void as a return type.

Proposed Fix

export interface FileUploadHandler {
  (file: FileUpload): void | null | File | string | Promise<void | null | File | string>;
}

This update allows the handler to return a File, string, null, void, or a Promise resolving to any of these types FormData accepts.

I’m happy to create a PR for this if that would be helpful.

mjackson commented 1 month ago

This makes a ton of sense to me. I'd be happy to merge a PR if you'd like to prepare one. Thank you! 🙏

lennerd commented 1 month ago

Perfect. I’m a bit busy with a deadline right now. I’ll try to get to it over the weekend.