java.lang.IllegalArgumentException: Illegal base64 character 3a

Viewed 1836

When I get a user from the database I want to add the string which tells the browser "ehy yo this is an image ok? good" to the profile picture field, except that's a byte array type so I have to encode it, add the string, then decode it again, all is good, except it isn't, because when I decode the string to make it a byte array again I get this error:

java.lang.IllegalArgumentException: Illegal base64 character 3a

this is the method:

    @GetMapping("/getUser")
    public UserEntity getUser(@RequestHeader("nickname") String nickname) {
        UserEntity user = userDAO.findUserByNickname(nickname);
        user.setPropic(decompressBytes(user.getPropic()));
        String propic = "data:image/jpeg;base64,"+ 
                        Base64Utils.encodeToString(user.getPropic());
        //this causes the error
        user.setPropic(Base64Utils.decodeFromString(propic)); 
        return user;
}

how can I solve this?

0 Answers
Related