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
- chore(common): Add complementary unit test Closes: #1198 — committed to tsedio/tsed by Romakita 3 years ago
- chore(common): Add complementary unit test Closes: #1198 — committed to tsedio/tsed by Romakita 3 years ago
- chore(common): Add complementary unit test Closes: #1198 — committed to tsedio/tsed by Romakita 3 years ago
- chore(common): Add complementary unit test Closes: #1198 — committed to tsedio/tsed by Romakita 3 years ago
- fix(#1198): Check if content-type is different to multipart/form-data Since the rawBody decorator support introducing, the multipart-file doesn't work as expected if an async middleware is used befor... — committed to tsedio/tsed by Romakita 3 years ago
- chore(common): Add complementary unit test Closes: #1198 — committed to tsedio/tsed by Romakita 3 years ago
- fix(#1198): Check if content-type is different to multipart/form-data Since the rawBody decorator support introducing, the multipart-file doesn't work as expected if an async middleware is used befor... — committed to tsedio/tsed by Romakita 3 years ago
🎉 This issue has been resolved in version 6.23.1 🎉
The release is available on:
v6.23.1Your 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