简体   繁体   中英

how to store user profile pictures in springboot rest api backend application

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?

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 eg as a base64-encoded String).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM