title: Fastest Way to Upload Multiple Image to Server in android
body: <p>I've multiple images to upload in server and i've a method for upload single image to server. now I'm using this method to send multiple images by creating loop for each images. </p>
  
  <p>Is there any fastest way to send multiple images to server?. Thanks in advance...</p>
  
  <pre><code>public int imageUpload(GroupInfoDO infoDO) {
          ObjectMapper mapper = new ObjectMapper();
          int groupId = 0;
          try {
              Bitmap bm = BitmapFactory.decodeFile(infoDO.getDpUrl());
              String fileName = infoDO.getDpUrl().substring(
                      infoDO.getDpUrl().lastIndexOf('/') + 1,
                      infoDO.getDpUrl().length());
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              bm.compress(CompressFormat.JPEG, 75, bos);
              byte[] data = bos.toByteArray();
              HttpClient httpClient = new DefaultHttpClient();
              HttpPost postRequest = new HttpPost(
                      "http://192.168.1.24:8081/REST/groupreg/upload");
              ByteArrayBody bab = new ByteArrayBody(data,
                      "application/octet-stream");
              MultipartEntity reqEntity = new MultipartEntity(
                      HttpMultipartMode.BROWSER_COMPATIBLE);
              reqEntity.addPart("uploadFile", bab);
              reqEntity.addPart("name", new StringBody(fileName));
              reqEntity.addPart("grpId", new StringBody(infoDO.getGlobalAppId()
                      + ""));
              postRequest.setEntity(reqEntity);
              HttpResponse response = httpClient.execute(postRequest);
              if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                  HttpEntity httpEntity = response.getEntity();
                  String json = EntityUtils.toString(httpEntity);
                  Map&lt;String, Object&gt; mapObject = mapper.readValue(json,
                          new TypeReference&lt;Map&lt;String, Object&gt;&gt;() {
                          });
                  if ((mapObject != null)
                          &amp;&amp; (mapObject.get("status").toString()
                                  .equalsIgnoreCase("SUCCESS"))) {
                      groupId = (Integer.valueOf(mapObject.get("groupId")
                              .toString()));
                  }
              }
          } catch (Exception e1) {
              e1.printStackTrace();
              Log.e("log_tag", "Error in http connection " + e1.toString());
          }
          return groupId;
      } 
  </code></pre>