'Saving images in MYSQL database user's column by Nestjs
** I want to store the user's images in my MySQL database this is my code **
UsersController
@Post("file-upload")
@UseInterceptors(
FileInterceptor("picture", {
storage: diskStorage({
destination: Helper.destinationPath,
filename: Helper.customFileName
})
})
)
uploadfile(id: string, updateUserDto: UpdateUserDto) {
return this.usersService.save( id, updateUserDto.picture);
}
UsersService
async save(id: string, updateUserDto: string): Promise<any> {
try {
await this.repository.save(id, updateUserDto);
} catch {enter code here
throw new InternalServerErrorException();
}
return {
message: "User Updated Successfully",
statusCode: HttpStatus.OK
};
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
