https://codebeautify.org/image-to-base64-converter website I use to convert image to base64 https://unsplash.com/photos/KaK2jp8ie8s image I am using
so using the image and website right above. I am converting this image into base64 and I am trying to save it into my spring boot h2 database. It won't let me saying it is not a byte[]. How could I do it?
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Data
public class Fromage implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String nom;
private double prix;
private int vieillese;
private int quantite;
@Lob
private byte[] data;
public Fromage(){}
public Fromage(String nom, double prix, int vieillese, int quantite, byte[] data) {
this.nom = nom;
this.prix = prix;
this.vieillese = vieillese;
this.quantite = quantite;
this.data = data;
}
}
byte[] bob = {1,2,3};
Fromage fromage = new Fromage("Chevre",50.15,10,1,bob);
fromageRepository.save(fromage);
trying to do this but replace bob with image base64 string