Copy and paste this decorator into the controller.
Check that the files directory has been created.
@UseInterceptors(
FileInterceptor('file', {
storage: diskStorage({
destination: './files',
filename: (req, file, cb) => {
const fileNameSplit = file.originalname.split('.');
const fileExt = fileNameSplit[fileNameSplit.length - 1];
cb(null, `${Date.now()}.${fileExt}`);
},
}),
}),
)
@Post("/upload")
create(
@UploadedFile() file: Express.Multer.File,
) {
console.log(file)
}