Skip to content

Can not process upload of 2 files with @tsed/platform-multer #3017

@AlexDede

Description

@AlexDede

Describe the bug

The code below works fine with @tsed/* version of 8.6.0 but has problems after migration to version 8.7.0 and @tsed/platform-multer

To Reproduce

  1. create a controller like this
import {Controller} from '@tsed/di';
import {MultipartFile, type PlatformMulterFile} from '@tsed/platform-multer';
import {Description, Post, Returns} from '@tsed/schema';

@Controller('/api/1.0')
export class MyController {

    @Returns(201)
    @Post('/test')
    @Description('Upload files')
    public async uploadFiles(@MultipartFile('file1') file1: PlatformMulterFile, @MultipartFile('file2') file2: PlatformMulterFile): Promise<void> {
    // some logic here
    }

}
  1. try to call this API from Postman or unit test
  2. The error will thrown:
Error: Unexpected end of form
    at Multipart._final (/Users/Work/Projects/test/node_modules/busboy/lib/types/multipart.js:588:17)
    at prefinish (node:internal/streams/writable:916:14)
    at finishMaybe (node:internal/streams/writable:930:5)
    at Multipart.Writable.end (node:internal/streams/writable:845:5)
    at onend (node:internal/streams/readable:948:10)
    at processTicksAndRejections (node:internal/process/task_queues:85:11) {
  storageErrors: []
}

Expected behavior

The server should process 2 files without any error

OS

MacOS

Node version

Node 22.14.0

Library version

8.7.0

Additional context

If the code above will be changed to

public async uploadFiles(@MultipartFile('files') files: PlatformMulterFile[]): Promise<void> {
    // some logic here
}

Everything will work fine. But this is not acceptable for my API.

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions