title: POST Request to upload multipart file in Spring Boot
body: <p>I'm using spring boot, I need to upload a multipart file (jpg or png file). I need to send a (POST request to upload the multi part file using "postman"), can anyone provide a screen shot of  "postman" of how to set it up to do that or tell me? Thanks.</p>
  
  <p>method : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@RequestMapping(method = RequestMethod.POST, value = "/upload")
   @ResponseBody
   ResponseEntity&lt;?&gt; writeUserProfilePhoto(@PathVariable Long user,  @RequestPart("file") MultipartFile file) throws Throwable {
    
    byte bytesForProfilePhoto[] = FileCopyUtils.copyToByteArray(file.getInputStream()); //Return an InputStream to read the contents of the file from.
    
    this.crmService.writeUserProfilePhoto(user, MediaType.parseMediaType(file.getContentType()),bytesForProfilePhoto);
    
    HttpHeaders httpHeaders = new HttpHeaders();
    
    URI uriOfPhoto = ServletUriComponentsBuilder.fromCurrentContextPath()
      .pathSegment(("/users" + "/{user}" + "/photo").substring(1))
      .buildAndExpand(Collections.singletonMap("user", user)).toUri();
    
    httpHeaders.setLocation(uriOfPhoto);
    return new ResponseEntity&lt;&gt;(httpHeaders, HttpStatus.CREATED);
   }</code></pre>
  </div>
  </div>
  </p>
  
  <p>and this is how I sent the POST request:<a href="https://i.stack.imgur.com/0xVzO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0xVzO.png" alt="enter image description here"></a></p>
  
  <p>my configuration class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@Configuration
  @ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class, MultipartConfigElement.class })
  @ConditionalOnProperty(prefix = "multipart", name = "enabled", matchIfMissing = true)
  @EnableConfigurationProperties(MultipartProperties.class)
  public class MultipartAutoConfiguration {
  
   @Autowired
   private MultipartProperties multipartProperties = new MultipartProperties();
  
   @Bean
   @ConditionalOnMissingBean
   public MultipartConfigElement multipartConfigElement() {
    return this.multipartProperties.createMultipartConfig();
   }
  
   @Bean(name = DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME)
   @ConditionalOnMissingBean(MultipartResolver.class)
   public StandardServletMultipartResolver multipartResolver() {
    return new StandardServletMultipartResolver();
   }
  
  }</code></pre>
  </div>
  </div>
  </p>