nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Handle files and multipart/form-data

Open silvercent011 opened this issue 3 years ago • 4 comments

Describe the feature

Should be great have a feature like multer on express and handle multipart/form-data on readBody() hook.

Additional information

  • [ ] Would you be willing to help implement this feature?

silvercent011 avatar Nov 27 '22 00:11 silvercent011

This is supported by H3, so this should work already.

export default eventHandler(async event => {
const form = await readMultipartFormData(event)
// do stuff
})

Implemented here https://github.com/unjs/h3/blob/5f503c23286e431a249bf379b6bb779d62e71059/src/utils/body.ts#L111

Hebilicious avatar Apr 25 '23 19:04 Hebilicious

Leaving this opens until this is documented.

Hebilicious avatar Jun 30 '23 23:06 Hebilicious

@Hebilicious Is it possible to limit what file types can be uploaded and what is the max file size? I see there is a type property but no file size.

Also I wonder if this counts as the documentation or is it still missing? https://www.jsdocs.io/package/h3#readMultipartFormData

MickL avatar Dec 26 '23 11:12 MickL

https://h3.unjs.io/utils/request#readmultipartformdataevent

Shyam-Chen avatar Feb 23 '24 09:02 Shyam-Chen