-3
Guys I have an entity that way:
I am using Spring Boot and Postman to instantiate new User class objects
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Entity
@Table(name = "tb_users")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "cod_user")
private Long id;
@Column(name = "name")
private String name;
@Column(name = "gender")
private String gender;
@Column(name = "birthday")
private LocalDate birthday;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "cod_address", unique = true)
private Address address;
private ??? profilePhoto;
My question is: How to upload an image and associate it to the profilePhoto attribute, so that when I instantiate a new object I can insert this profile image in the user’s creation?
NOTE: I am not using Spring MVC or Thymeleaf, only Spring Boot and making the requests via Postman, in which case to create a new instance I am passing a JSON:
{
"name": "Gui",
"gender": "male",
"birthday": "1998-12-12",
"address":{
"address": "Rua da Neves",
"city": "Niterói",
"state": "Rio de Janeiro",
"postalCode": "579777-90",
"country": "Brazil"
},
"profilePhoto": ???
How can I pass in my User Controller a way to create this image and associate to the profilePhoto attribute?
@PostMapping("/create")
@ResponseStatus(HttpStatus.CREATED)
public Person create(@RequestBody Person person) {
return personService.create(person);
}