Skip to content

fix: UploadedFile returns undefined value #1012

@mrdavidrees

Description

@mrdavidrees

Description

I upgraded from 0.9.0 today to 0.10.1
Now the UploadedFile decorator is returning undefined.
The context clearly shows the file with the matching field name.

Minimal code-snippet showcasing the problem

export const fileUploadConfig = {
  options: {
    fileFilter: (
      req: any,
      file: Express.Multer.File,
      cb: (error: any | null, pass: boolean) => void,
    ) => {
      console.log(file);  //{fieldname: 'file', originalname: '...
      cb(null, true);
    },
  },
};

  @Post('/upload_file')
  async uploadFile(
    @Ctx() context: Context,
    @UploadedFile('file', fileUploadConfig) body: Express.Multer.File,
  ) {
    console.log(context.file) //{fieldname: 'file', originalname: '...
    console.log(body) //undefined
    return "this is broken";
  }

using recommended packages.
"@koa/multer": "3.0.2",
"multer": "1.4.4",

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions