Reputation: 409
i want use multer in my nestJs application like this:
@Post()
@UseInterceptors(
FileInterceptor('file', {
storage: diskStorage({
destination: './files',
}),
}),
)
async upload(@Request() req, @Query() query: any, @UploadedFile() file) {
console.log(file);
}
But my IDE (vscode) keeps saying: Cannot find name 'diskStorage' and is not compiling. I also register the MulterModule on the specified Module (FeatureModule).
I can use
@UseInterceptors(
FileInterceptor('file', { dest: '/data-path'}),
)
But i want change the filename for example. For this I need the diskStorage function
What can i do, to resolve the issue?
Upvotes: 3
Views: 5531
Reputation: 409
the solution was as described by @JayMcDoniel An extra import had to be made.
import { diskStorage } from 'multer';
With the help of this example, I was able to recreate and solve the whole thing again. https://github.com/TannerGabriel/Blog/tree/091cbf99bc9409629e1ab717ca8ec405c421d6d4/nest-file-uploading
Upvotes: 7