title: Upload multiple files with progress bar using OKHTTP3
body: <pre><code>public class CountingFileRequestBody extends RequestBody {
  
      private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
  
      private final File file;
      private final ProgressListener listener;
      private final String contentType;
  
      public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
          this.file = file;
          this.contentType = contentType;
          this.listener = listener;
      }
  
      @Override
      public long contentLength() {
          return file.length();
      }
  
      @Override
      public MediaType contentType() {
          return MediaType.parse(contentType);
      }
  
      @Override
      public void writeTo(BufferedSink sink) throws IOException {
          Source source = null;
          try {
              source = Okio.source(file);
              long total = 0;
              long read;
  
              while ((read = source.read(sink.buffer(), SEGMENT_SIZE)) != -1) {
                  total += read;
                  sink.flush();
                  this.listener.transferred(total);
  
              }
          } finally {
              Util.closeQuietly(source);
          }
      }
  
      public interface ProgressListener {
          void transferred(long num);
      }
  
  }
  </code></pre>
  
  <p>I saw the above code for getting the progress of a file upload... And The code is used like this</p>
  
  <pre><code>RequestBody requestBody = new MultipartBuilder()
          .type(MultipartBuilder.FORM)
          .addPart(
                  Headers.of("Content-Disposition", "form-data; name=\"image\"; filename=\"" + file.getName() + "\""),
                  new CountingFileRequestBody(file, "image/*", new CountingFileRequestBody.ProgressListener() {
                      @Override
                      public void transferred(long num) {
                          float progress = (num / (float) totalSize) * 100;
                          uploadData.progressValue = (int) progress;
                          handler.post(new Runnable() {
                              @Override
                              public void run() {
                                  updateProgressBar(tempId);
                              }
                          });
                      }
                  })
          )
          .build();
  Request request = new Request.Builder()
          .tag(tempId)
          .url(Constants.BASE_URL + apiPath)
          .post(requestBody)
          .build();
  </code></pre>
  
  <p>But the code works for only single file upload, I am still new to JAVA so I don't know how to change the code to suit my multiple files upload...</p>
  
  <p>Below is my code for my files upload</p>
  
  <pre><code>MultipartBody.Builder multipartBody = new MultipartBody.Builder().setType(MultipartBody.FORM);
  for (int g = 0; g &lt; fileLists.size(); g++){
      File file = fileLists.get(g);
      multipartBody.addFormDataPart("files[]", file.getName(), RequestBody.create(MediaType.parse("*/*"), file));
  }
  multipartBody.addFormDataPart("lang", lang)
          .addFormDataPart("user", myIDtoString)
          .addFormDataPart("post", postText);
  RequestBody requestBody = multipartBody.build();
  Request request = new Request.Builder()
          .url(Constants.submitPostUrl)
          .post(requestBody)
          .build();
  </code></pre>
  
  <p>Please How can I modify the Java Class code to suit my upload code</p>