title: Uploading image to a Spring-Boot web server from android
body: <p>I am using retrofit 2 library to send image from android device to a server which runs on Spring - Boot. 
  I want to simply send an image to see, if all is ok, so i perform this simple type of request: </p>
  
  <p>On server side my controller looks like this:</p>
  
  <pre><code> @PostMapping(value = "/updatePhoto" )
  public String updateUserPhoto(@RequestPart(name = "img") MultipartFile img) {
      {
          System.out.println("Request  update photo "+ img.getOriginalFilename());
          return "OK";
      }
  </code></pre>
  
  <p>This is my request </p>
  
  <pre><code>@POST("/updatePhoto")
  @Multipart
  Call&lt;String&gt; updateUserPhoto(@Part MultipartBody.Part img);
  </code></pre>
  
  <p>This is how i perform it:</p>
  
  <pre><code> File file = new File(mediaPath);
          RequestBody requestBody = RequestBody.create(MediaType.parse("*/*"), file);
          MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
  
  
          System.err.println(filename+"  " + fileToUpload);
          MainAplication.getServerRequests().updateUserPhoto(fileToUpload)
                  .enqueue(new Callback&lt;String&gt;() {
                      @Override
                      public void onResponse(Call&lt;String&gt; call, Response&lt;String&gt; response) {
                          if(response.body()!=null){
                              System.err.println(response.body());
                          }else{
                              System.err.println("RESPONSE BODY NULL");
                          }
                      }
  
                      @Override
                      public void onFailure(Call&lt;String&gt; call, Throwable t) {
                          System.err.println("UPDATE PHOTO FAIL " +t.getMessage());
                      }
                  });
  </code></pre>
  
  <p>But every time i try to send an image, my server throws an exception :</p>
  
  <pre><code>org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'img' is not present
  </code></pre>
  
  <p>And can<code>t understand where i</code>m doing wrong, i had  tried a lot, but a can`t solve this problem. Any ideas what must i improve ?</p>