title: "Retrofit" multiple images attached in one multipart request
body: <p>Is there any way to attached multiple images in one multipart request? The images is dynamic based on the number of images that user has picked.</p>
  
  <p>Below code only works for single image:</p>
  
  <p>Interface:</p>
  
  <pre><code>@Multipart
  @POST("/post")
  void createPostWithAttachments( @Part("f[]") TypedFile image,@PartMap Map&lt;String, String&gt; params,Callback&lt;String&gt; response);
  </code></pre>
  
  <p>Implementation:</p>
  
  <pre><code>TypedFile file = new TypedFile("image/jpg", new File(gallery.sdcardPath));
  
  Map&lt;String,String&gt; params = new HashMap&lt;String,String&gt;();
  params.put("key","value");
  
  ServicesAdapter.getAuthorizeService().createPostWithAttachments(file,params, new Callback&lt;String&gt;() {
          @Override
          public void success(String s, Response response) {
              DBLogin.updateCookie(response);
              new_post_text.setText("");
              try {
                  JSONObject json_response = new JSONObject(s);
                  Toast.makeText(getApplicationContext(), json_response.getString("message"), Toast.LENGTH_LONG).show();
                  if (json_response.getString("status").equals("success")) {
                      JSONObject dataObj = json_response.getJSONObject("data");
                      Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                      startActivity(intent);
                      finish();
                  } else {
                      Log.d(TAG, "Request failed");
                  }
              } catch (Exception e) {
                  Log.d(TAG, e.getMessage());
              }
          }
  
          @Override
          public void failure(RetrofitError retrofitError) {
              Toast.makeText(getApplicationContext(), retrofitError.getMessage(), Toast.LENGTH_LONG).show();
          }
      });
  </code></pre>