tsed: [V6][BUG/QUESTION] request.file is undefined in >= 6.20.0

These 2 examples don’t work starting with v 6.20.0 https://github.com/TypedProject/tsed/compare/v6.19.2...v6.20.0

request.file is undefined

Example 1

@Post('/my-image/:id')
@Use(upload.single('myimage')) // frontend sends me `myimage` field
public uploadMyIng(
  @Req() request,
) {
  // request.file is undefined
}

Example 2

private getFileConfig(myType: myEnum) {
  return {
    storage: multer.diskStorage({
      destination: (req: Express.Request, _fileItem, cb) => {
        const path = 'resolve path here depends on myType param';
        cb(null, path);
      },
      filename: (req, fileItem, callback) => {
        // handle filename
      },
    }),
    fileFilter: (req, fileItem, callback) => {
      // filter file
    },
  };
}

  @Post('/upload')
  @MulterOptions(getFileConfig(myEnum.A)) // now pass config here
  public async uploadDoc(
    @MultipartFile('file') file: PlatformMulterFile, // frontend sends me `file` field
    @BodyParams('id') id: number,
  ) {
    // request.file is undefined
  }

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20

Commits related to this issue

Most upvoted comments

🎉 This issue has been resolved in version 6.23.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

I confirm it’s working for me now, the sample project from above and the other project i’m working on. Thanks so much for the quick fix!

@daveruiz Thanks for the repository 😉. Thanks to your analysis I found the problem. It’s related to the support of rawBody added recently. I’ll fix that immediatly! thanks again for your help!

@Romakita Ok! Anyway, I’ve got a basic project that reproduces the issue. https://github.com/daveruiz/tsed-multer-issue

Thanks for your work here!

@daveruiz Don’t add PlatformMulterMiddleware manually please. This is not the normal usage.

Again, give me a repository with reproducible example before adding more messages… I already covered this scenario with integration test, and all works fine!

See you Romain