title: Multipartfile in java dto
body: <blockquote>
    <p>My requirement is, I would like to get json data along with file.<br>
    <strong>User can upload file and send his data as (eg. name, email, image);</strong></p>
  </blockquote>
  
  <p>I have a simple DTO looks like this (below)</p>
  
  <pre><code>public class SampleDTO {
  
      private String sample1;
      private MultipartFile file;
  
      public String getSample1() {
          return sample1;
      }
      public MultipartFile getFile() {
          return file;
      }
      public void setSample1(String sample1) {
          this.sample1 = sample1;
      }
      public void setFile(MultipartFile file) {
          this.file = file;
      }
  }
  </code></pre>
  
  <p>I have a sample API look like this (below)</p>
  
  <pre><code>@PostMapping("/sampleAPI")
  public void sampleAPI(@RequestBody SampleDTO sampleDto) {
   log.info("sampleDto"+sampleDto);
   log.info("sampleDtoFile"+sampleDto.getFile());
   log.info("sampleDtoSample1"+sampleDto.getSample1());
  }
  </code></pre>
  
  <p>If I call this API, No logs are printed and I get this type of error  (<code>Internal server error</code>). What I am doing wrong here ?</p>
  
  <p>I used Postman's <code>formdata</code> as body, and in javascript <code>new FormData()</code> as API body.</p>