title: [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present
body: <p>I am uploading .pdf file to mongo DB, I am using GridFS Template.</p>
  <p>FileController.java</p>
  <pre><code>@RequestMapping(value = &quot;/upload&quot;, method = RequestMethod.POST, 
  produces = MediaType.APPLICATION_JSON_VALUE)
   public ResponseEntity&lt;?&gt; 
   upload(@RequestParam(&quot;file&quot;)MultipartFile file) throws 
   IOException 
    {
      return new ResponseEntity&lt;&gt;(fileService.addFile(file), 
      HttpStatus.OK);
  }
  </code></pre>
  <p>FileService.java</p>
  <p>public String addFile(MultipartFile upload) throws IOException {</p>
  <pre><code>    //define additional metadata
      DBObject metadata = new BasicDBObject();
      metadata.put(&quot;fileSize&quot;, upload.getSize());
  
      //store in database which returns the objectID
      Object fileID = template.store(upload.getInputStream(), upload.getOriginalFilename(), upload.getContentType(), metadata);
  
      //return as a string
      return fileID.toString();
  }
  </code></pre>
  <p>After writing controller and service method, I am getting this error:</p>
  <blockquote>
  <p>[org.springframework.web.multipart.support.MissingServletRequestPartException:
  Required request part 'file' is not present]</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/GfEIb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GfEIb.png" alt="enter image description here" /></a></p>
  <p>Can anyone please help me, why I am getting this exception?</p>
  <p>Thank you</p>