I am a self-learner. When I try to upload an image with some additional data postman returns this error... Has anyone any idea about this..?
This is my controller method :
@Post()
@UseInterceptors(FileInterceptor('file'))
async create(
@UploadedFile() file: Express.Multer.File,
@Body() createItemDto: CreateItemDto,
) {
console.log('item', createItemDto);
console.log('file', file);
// try {
// const item = await this.itemService.create(createItemDto);
// return {
// statusCode: HttpStatus.OK,
// message: 'Item created successfully',
// item,
// };
// } catch (error) {
// return {
// message: error.detail,
// };
// }
}
The file
option passed to the FileInterceptor
is incorrect according to the postman
request. It should be FileInterceptor('image')
not FileInterceptor('file')