TypeError: Could not parse content as FormData.
See original GitHub issueWhat version of Remix are you using?
1.5.1
Steps to Reproduce
1.5.1 introduces breaking change on how unstable_parseMultipartFormData works.
Before 1.5.1 unstable_parseMultipartFormData
wouldn’t care if your form had enctype="multipart/form-data"
, but now there is a check that throws TypeError: Could not parse content as FormData.
.
To fix it make sure you include the enctype
in your forms.
Also you need to update your uploadHandler to include memory upload handler. Something like this:
export const uploadHandler = unstable_composeUploadHandlers(
unstable_createFileUploadHandler({
avoidFileConflicts: true,
directory: '/tmp',
file: ({filename}) => filename,
maxPartSize: 5_000_000,
}),
unstable_createMemoryUploadHandler(),
);
I know these are unstable APIs, but if the team could point out the breaking changes next time in the release notes that would be great.
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Could not parse content as FormData. ...
I have a simple python server that is sending a multipart response to a javascript client, but I get this error TypeError: Could...
Read more >multipart/form-data fetch cannot be parsed with Response. ...
formData method on the result, yielding "TypeError: Could not parse content as FormData.". Expected results: One should be able to use the .formData...
Read more >Wink error parsing multipart form-data with ...
If I include the content-type: multipart/form-data I get this: "Error 500: ... I did find this https://issues.apache.org/jira/browse/WINK-371 but is this ...
Read more >Could not parse request with message: Missing boundary ...
For requests with Content-Type “multipart/form-data” the body of the requests must be structured according to the rules of that content type.
Read more >Solved: application/x-www-form-urlencoded content type err...
Then this part of the content cannot be used in Parse JSON, because its type is clearly application / x-www-form-urlencoded and not JSON....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, @CanRau, this solved issue for me. Perhaps there’s some way to add this to Remix linter?
@LukasCornille, look at my comment on composing the handlers. The uploadHandler only handles the file part of the formData, you need the
memoryUploadHandler
to parse the POST fields.