I am trying to save a file in the Database.

Here's my code.

```
public class DocumentForm {

    @NotNull
    @Size(min = 1)
    private byte[] file;

    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

...
}

```

Controller

```
@RequestMapping(value = "document", method = RequestMethod.POST)
public String signup(@Valid @ModelAttribute DocumentForm documentForm, Errors errors, RedirectAttributes ra) {
    if (errors.hasErrors()) {
        return "document/document";
    }
    Document d = projectRepository.save(documentForm.createDoc());
    MessageHelper.addSuccessAttribute(ra, "document.success");
    return "redirect:/";
}

```

view

```
    <input type="file" name="file" class="btn"></input>
<button type="submit" class="btn">Submit</button>

```

In the database:

It shows that the image is saved as a `BLOB`.

![enter image description here](https://i.stack.imgur.com/vroSE.png)

However, when i try to view the image, by clicking on `Open Value in Editor` in mySQL browser, What i see is only the name of the image file.

How can i save an image in the MySQL DB ? and how can i retrieve it and display on my View