title: Upload picture to server using retrofit 2
body: <p>First of all lets look to the code:</p>
  
  <pre><code>public interface ApiInterface {
      @Multipart
      @POST("my/files/photo/")
      Call&lt;FileUploadResponse&gt; uploadPhoto(@Header("authorization") String auth,
                                       @Part MultipartBody.Part file,
                                       @Part("file-type") RequestBody fileType);
  }
  </code></pre>
  
  <p>I'm calling this interface like this:</p>
  
  <pre><code>RequestBody body = RequestBody.create(MediaType
              .parse(getContentResolver().getType(fileUri)), file);
  MultipartBody.Part avatarBody = MultipartBody.Part
              .createFormData(data, file.getName(), body);
  RequestBody fileType = RequestBody.create(
              MediaType.parse("text/plain"), "profile");
  client.uploadPhoto(getToken(), avatarBody, fileType);
  </code></pre>
  
  <p>From server i'm getting response that "File type not provided". If i change places of file and filetype on uploadPhoto function like this:</p>
  
  <pre><code>@Multipart
  @POST("my/files/photo/")
  Call&lt;FileUploadResponse&gt; uploadPhoto(@Header("authorization") String auth,
                                   @Part("file-type") RequestBody fileType
                                   @Part MultipartBody.Part file);
  </code></pre>
  
  <p>I'm getting response "File not provided".
  I've checked server with my own code written on JS:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;script language="JavaScript" type="text/javascript" src="C://Users/User/Downloads/jquery-3.2.1.min.js"&gt;&lt;/script&gt;
  
  &lt;form action=""&gt;
    &lt;input type="text" name="authorize" id="authorize"&gt;
    &lt;br&gt;
    &lt;input type="file" name="photo" accept="image/*" id="filechooser" onchange="onFileChange(this)" &gt;
    &lt;br&gt;
    &lt;input value="profile" type="text" name="file-type" id="type"&gt;
    &lt;br&gt;
    &lt;input type="button" onclick="uploadFile()"&gt;
  &lt;/form&gt;
  
  
  &lt;script&gt;
  var blobFile;
  function onFileChange(ss) {
   blobFile = ss.files[0];
   alert(blobFile);
  }
  function uploadFile() {
  
   var storedJWT = $('#authorize').val();
   var fileType = $('#type').val();
      var formData = new FormData();
      formData.append("file-type", fileType);
   formData.append("photo", blobFile);
   console.log(storedJWT);
      $.ajax({
         url: "url",
         type: "POST",
         data: formData,
      headers: {
          authorization: storedJWT
      },
         processData: false,
         contentType: false,
         success: function(response) {
       console.log(response);
         },
         error: function(jqXHR, textStatus, errorMessage) {
             console.log(errorMessage);
         }
      });
  }&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>everything working fine. Script on JS generating request like this:</p>
  
  <pre><code>Accept:*/*
  Accept-Encoding:gzip, deflate
  Accept-Language:en-US,en;q=0.8
  authorization:JWT token
  Connection:keep-alive
  Content-Length:67601
  Content-Type:multipart/form-data; boundary=----
  WebKitFormBoundary3MtpMA70hG41luF1
  Host:localhost
  ------WebKitFormBoundary3MtpMA70hG41luF1
  Content-Disposition: form-data; name="file-type"
  
  profile
  ------WebKitFormBoundary3MtpMA70hG41luF1
  Content-Disposition: form-data; name="photo"; filename="1231231313.jpg"
  Content-Type: image/jpeg
  
  
  ------WebKitFormBoundary3MtpMA70hG41luF1--
  </code></pre>
  
  <p>and the retrofit request is:</p>
  
  <pre><code>Content-Type: multipart/form-data; boundary=238182ad-d99c-4d44-9ba6-7d178a14b2e9
  Content-Length: 59776
  authorization: JWT token
  --238182ad-d99c-4d44-9ba6-7d178a14b2e9
  Content-Disposition: form-data; name="photo"; filename="1502703422332.jpg"
  Content-Type: image/jpeg
  Content-Length: 59369
  //bytes
  --238182ad-d99c-4d44-9ba6-7d178a14b2e9
  Content-Disposition: form-data; name="file-type"
  Content-Transfer-Encoding: binary
  Content-Type: text/plain; charset=utf-8
  Content-Length: 7
  profile
  --238182ad-d99c-4d44-9ba6-7d178a14b2e9--
  </code></pre>
  
  <p>I can't understand where can be error...</p>