The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.
I decided to remove the Files[] because I noticed that when form parses a request with more than one image, it does not put the images inside an array but inside a literal object. Therefore, you can access any of these images by using the input's name property in the form tag.
Support plan
Context
What are you trying to achieve or the steps to reproduce?
I was trying to access the
path
property from thefiles
parameter, but I got the commented error below:What was the result you got?
At runtime, I get the
path
value, but TS complains aboutpath
not being defined when I'm coding.What result did you expect?
I expect TS to understand that sometimes I get only one file, not an array of files.
The workaround I found is: you need to install the types for formidable with
@types/formidable
, go toindex.d.ts
and, at line 180, change:to:
I decided to remove the
Files[]
because I noticed that whenform
parses a request with more than one image, it does not put the images inside an array but inside a literal object. Therefore, you can access any of these images by using the input's name property in the form tag.I create a repo to show this issue here.