title: How to store an image in the database using Angular 4 and Spring
body: <p>I'm using Angular 4 for the Front-end and Spring for the Back-end and I wanna store a user which contains an image in my database.
  As i know the type <strong>Blob</strong> exists in <strong>Angular 4</strong> but it doesn't in Spring, and the type <strong>byte</strong> exists in <strong>Spring</strong> but it doesn't in Angular 4.
  How can I transfer my image from the Front-end to the Back-end using REST API.</p>
  
  <p>This is my entity:</p>
  
  <pre><code>import java.sql.Blob;
  @Entity
  @Table(name = "USER_OAUTH", schema = "OAUTH")
  public class UserOauth implements java.io.Serializable {
   private long idUser;
   private String username;
   private String firstName;
   private String lastName;
   private String adrEmail;
   private int isAdAccount;
   private Date lastConnection;
   private String password;
   private boolean enabled;
   private int attempts;
   private Blob photo;
  
  @Lob
  @Column(name = "PHOTO", length = 10000000)
  public Blob getPhoto() {
      return photo;
  }
  </code></pre>
  
  <p>This is my DTO :</p>
  
  <pre><code>public class UserDTO implements java.io.Serializable {
  
   private long idUser;
   private String username;
   private String firstName;
   private String lastName;
   private String adrEmail;
   private int isAdAccount;
   private Date lastConnection;
   private String password;
   private boolean enabled;
   private Blob photo;
  </code></pre>
  
  <p>This is my web service :(it works normally before adding the photo):</p>
  
  <pre><code>// Add a new user;
  @RequestMapping(value = "/users", method = RequestMethod.POST)
  public UserDTO addUser(@RequestBody final UserDTO user) throws Exception {
      return modelMapper.map(userService.saveUser(modelMapper.map(user, UserOauth.class)), UserDTO.class);
  }
  </code></pre>
  
  <p>And finally my Typescript :</p>
  
  <pre><code>export class UserData {
    public  idUser: number;
    public  username: string;
    public  firstName: string;
    public  lastName: string;
    public  adrEmail: string;
    public  isAdAccount: boolean;
    public  lastConnection: Date;
    public  password: string;
    public  enabled: boolean;
    public  photo:Blob;
  }
  </code></pre>
  
  <p>If there is any rectifications please let me know.
  Thank you in advance</p>