solidjs/solid-router

0.14 breaks FormData file serialisation

plushdohn opened this issue ยท 3 comments

Describe the bug

Version 0.14 and above seems to have broken file uploads done via a server action's formData argument. Files on a Node server get serialised and look like an [object File] instead of an actual File so it's impossible to get the underlying buffer anymore.

This single commit bd9f19a seems to be causing the bug as undoing those precise changes fixes the issue.

Your Example Website or App

https://stackblitz.com/~/github.com/plushdohn/solid-start/tree/plushdohn/repro-formdata?file=examples/basic/src/routes/index.tsx

Steps to Reproduce the Bug or Issue

  1. Create a <form> that uses a server action from the router and has a file input
  2. Do a formData.get("file") on the server and console.log the output
  3. Revert to 0.13.6 to fix the bug

Expected behavior

I know there are limitations in file upload via FormData but I'd expect the default behaviour to work

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 0.14.1

Additional context

I'd gladly make a PR but I don't have context on why the initial change was made.

I think your form just misses the enctype="multipart/form-data" attribute for file uploads. Before 0.14 all forms where implicitly sent with this attribute which was inconsistent with the html standard ๐Ÿ˜….

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype
Goes into more detail about this

I think your form just misses the enctype="multipart/form-data" attribute for file uploads. Before 0.14 all forms where implicitly sent with this attribute which was inconsistent with the html standard ๐Ÿ˜….

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/enctype Goes into more detail about this

TIL about enctype, cheers!