Skip to content

UploadFile() should accept Readable instead of Buffer #13158

Open
@samchon

Description

@samchon

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

When using @UploadFile() decorator following the NestJS guide documents, it becomes Buffer type.

As you know, the Buffer type means that backend server gathers entire data of the uploaded file. If client uploads 1GB file through the API, the NestJS backend server requires at least 1GB memory about the request. If there're 100 clients uploading the 1GB file at the same time, NestJS backend server needs 100GB memory at that time.

Describe the solution you'd like

I know that the default option of multer is using the Buffer type instance, but it seems not proper to the full framework like NestJS. If configure storage engine of the multer, the uploadaed file would be Readable stream type, and I think NestJS should do it.

Teachability, documentation, adoption, migration strategy

I have followed the https://docs.nestjs.com/techniques/file-upload document.

And very surprised by too much memory consumption.

What is the motivation / use case for changing the behavior?

I think NestJS should do like below:

  1. Make streaming to be default
  2. When some users want Buffer feature, they must configure by themselves
  3. If hard to migrate, then have to warn those facts in the guide documents

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions