Issue
I am working in backend part with spring boot and rest api. I need to store user details in database. The question is what is best approach to handle user profile pictures in the server. how to use @POST AND @GET methods in that case?
Solution
Use POST
to store the picture on the server, GET
to receive it and display it to the user.
Update You could try something like this:
@RequestMapping(value = "/api/image/save", method = RequestMethod.POST)
public void addImage(@RequestBody Image image) {
imageService.addImage(image);
}
This is what you put inside your controller. Then you need an imageService
-instance which stores the image in the database. And you have an Image
-class that contains the image data (image comes in e.g. as a base64-encoded String).
Answered By - user7291698
Answer Checked By - David Goodson (JavaFixing Volunteer)