title: How to reduce size of a multipart file in java
body: <p>I have <code>Java</code> <code>Spring MVC</code>  application in which there is an option to upload an image and save to the server. i have the following method:</p>
  
  <pre><code>@RequestMapping(value = "/uploaddocimagecontentsubmit", method = RequestMethod.POST)
  public String createUpdateFileImageContentSubmit(@RequestParam("file") MultipartFile file, ModelMap model)
  {
  //methods to handle file upload
  }
  </code></pre>
  
  <p>I am now trying to reduce the size of the image refering the following:</p>
  
  <p><a href="https://stackoverflow.com/questions/13977858/increasing-resolution-and-reducing-size-of-an-image-in-java/14050844#14050844">increasing-resolution-and-reducing-size-of-an-image-in-java</a> and <a href="https://stackoverflow.com/questions/6390964/decrease-image-resolution-in-java">decrease-image-resolution-in-java</a>
  The problem I am facing is that in the above examples, we are dealing with <code>java.io.File</code> Objects which are saved to a specified location. I dont want to save the image. Is there any way that I can use something similar to compress my Multipart Image file and continue with the upload.</p>