I have the following controller :
createCollection(
@UploadedFile() file,
@Body() createCollectionDto: CreateCollectionDto,
@GetUser() user: User,
): Promise<Collection> {
this.logger.verbose(
`User "${
user.username
}" creating a new collection. Data: ${JSON.stringify(
createCollectionDto,
)} of "${user.username}"`,
);
if (file) {
return this.collectionService.createCollection(
createCollectionDto,
user,
file,
);
} else {
throw new InternalServerErrorException('File needed');
}
}
I need to upload a file and In the same query give some data.
Because I want to upload a file, I set up Postman like this:
First Question : How can I send the file along with the data showed in picture n°1 ?
I searched another tool for API requests and I found Postwoman
But the response is always the same: It doesn't detects the data. (i.e. { name: foo, color: bar}
)
Second Question : How can I solve this issue ? Is it possible to put data along a file ? If it is possible how can I achieve that in NestJS ?
Thank you very much for reading my question :) Any help would be appreciated.