I have a class of Achievement with an image which is byte[].
@Entity
@Table(name = "ACHIEVEMENT")
public class Achievement {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long achievementId;
private byte[] image;
THe problem is that the user send an image URL to the endpoint of create
{
"image": "https://img.favpng.com/13/18/21/computer-icons-achievement-trophy-award-png-favpng-TYahJ0mkcwhJYqA1BPqKcSibe.jpg",
}
public ResponseEntity<?> createAchievement(@RequestBody Achievement achievement)
Spring throws error when reading the request body and doesn't even allow me to convert the image to a byte array.
JSON parse error: Cannot deserialize value of type
byte[]
from String "//img.favpng.com/13/18/21/computer-icons-achievement-trophy-award-png-favpng-TYahJ0mkcwhJYqA1BPqKcSibe.jpg": Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character ':' (code 0x3a) in base64 content;
What can I do to allow the String to be passed to the endpoint so I can convert to a byte array?