title: retrofit 2 multipart send only array file instead of part with array
body: <p>I'm trying to send a POST using multipart/form-data. I faced some problems, which were resolved at this forum, like extra quotes and how to send several files. But now, I would like to send my files with unique names inside of one array. I will attach two files to express better what I want to do.</p>
  
  <p>I'm receiving the files like this ...</p>
  
  <p><a href="https://i.stack.imgur.com/7bY6Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7bY6Q.png" alt="wrong structure"></a></p>
  
  <p>and I want to receive my files like this ...</p>
  
  <p><a href="https://i.stack.imgur.com/4etFA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4etFA.png" alt="correct structure"></a></p>
  
  <p>is it possible to change the body data structure using retrofit 2? I would like to change the mimetype data from multipart/form-data to image/jpeg.</p>
  
  <p>Some code</p>
  
  <pre><code>HashMap&lt;String, RequestBody&gt; files = attachFile();
  
      api.createPlant(plant.getName(),
              plant.getSize(), plant.getPhSoil(), plant.getEcSoil(), plant.getGardenId(), files)
              .subscribeOn(Schedulers.newThread())
              .observeOn(AndroidSchedulers.mainThread())
              .subscribe(new Subscriber&lt;Plant&gt;() {
                  @Override
                  public final void onCompleted() {
                      Log.e(TAG, "on completed");
                  }
  
                  @Override
                  public final void onError(Throwable e) {
                      Log.e(TAG, e.getMessage());
                  }
  
                  @Override
                  public final void onNext(Plant response) {
                      mBody.setText(response.toString());
                  }
              });
  
  private HashMap&lt;String, RequestBody&gt; attachFile() {
  
      ArrayList&lt;String&gt; listOfNames = new ArrayList&lt;&gt;();
      listOfNames.add("images");
      listOfNames.add("mango-lg2");
  
      HashMap&lt;String, RequestBody&gt; map = new HashMap&lt;&gt;(listOfNames.size());
      RequestBody file = null;
      File f = null;
  
      for(int i = 0, size = listOfNames.size(); i&lt;size;i++){
  
          try {
  
              File folder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
  
              f = new File(folder, listOfNames.get(i) + ".jpg");
  
              Bitmap bitmap = convertFileToBitmap(f);
  
              if(bitmap != null){
                  FileOutputStream fos = new FileOutputStream(f);
                  bitmap.compress(Bitmap.CompressFormat.JPEG, 0 /*ignored for PNG*/, fos);
                  fos.flush();
                  fos.close();
              }else{
                  Log.i("INFO", "imageNotFound");
                  return null;
              }
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
  
          file = RequestBody.create(MediaType.parse("multipart/form-data"), f);
          map.put("file\"; filename=\"" + listOfNames.get(i) + ".jpg",file);
          file = null;
          f = null;
      }
      return map;
  }
  </code></pre>