nestia icon indicating copy to clipboard operation
nestia copied to clipboard

Add option to pass `multer` options to Multipart uploads

Open fgodino-milu opened this issue 1 year ago • 7 comments
trafficstars

Feature Request

Problem

Currently, @TypedFormData.Body() uses multer to read and store file uploads but it doesn't support passing options to the multer singleton.

I am trying to use DiskStorage to store uploads but multer uses MemoryStorage by default.

Additionally, the type of files within @TypedFormData.Body() is File, which hides a lot of the information in Express.Multer.File types and it's not supported in Node versions prior two 20.

Request

  1. Add option to be able to pass multer options to multipart uploads
  2. Use Express.Multer.File type instead of File for files (see https://expressjs.com/en/resources/middleware/multer.html#api)

Thanks!

fgodino-milu avatar Mar 01 '24 08:03 fgodino-milu

As I also have to consider the fastify case, supporting express-multer options are not easy problem.

Will you suggest or send a PR that can make both express and fastify compatible?

samchon avatar Mar 03 '24 07:03 samchon

Hi @samchon

I found this package https://www.npmjs.com/package/fastify-multer, which is a port of express-multer. It supports the same options and it outputs the same output types.

I think using this library would simplify it a bit.

Let me know what you think

fgodino-milu avatar Mar 04 '24 10:03 fgodino-milu

Seems good. What about challenge a PR in here code?

https://github.com/samchon/nestia/blob/master/packages/core/src/decorators/TypedFormData.ts

samchon avatar Mar 04 '24 10:03 samchon