First of all, i am aware that saving a Base64 string in the database is not the most efficient way to save images, but i do not have a lot of them and load them rarely, so that should not be a problem.
So lets start, i have a SQL database with a table "pictures" which has two column, a unique name and a string representing a file in base 64:
@Entity
public class Picture {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(unique = true)
private String name;
private String imageInBase64;
}
A user is able to select an image in the user interface which then gets send to the backend via REST. My question is, should i encode the file/picture to Base64 before sending it to the backend or should i encode it in the backend after receiving it? Currently i just encode it in the frontend and send a JSON representing the Picture class.