title: How to Upload Bitmap Images with Retrofit?
body: <p>In my App i need to enable the user to upload 6 images as max from gallery after resize the images to Bitmaps, i have finished the selecting and resizing part successfully as shown below code and store the results in array of bitmaps <strong>imageslist</strong> .
  My question is How to upload my bitmaps array using Retrofit MultipartBody ?? all the topics of Retrofit talking about file upload via file path like the answer of this question which i can't upload the files directly before resize</p>
  
  <p><a href="https://stackoverflow.com/questions/39866676/retrofit-uploading-multiple-images-to-a-single-key">Retrofit Uploading multiple images to a single key</a></p>
  
  <p>This is my code :</p>
  
  <pre><code> private static Bitmap resize(Bitmap image, int maxWidth, int maxHeight) {
          if (maxHeight &gt; 0 &amp;&amp; maxWidth &gt; 0) {
              int width = image.getWidth();
              int height = image.getHeight();
              float ratioBitmap = (float) width / (float) height;
              float ratioMax = (float) maxWidth / (float) maxHeight;
  
              int finalWidth = maxWidth;
              int finalHeight = maxHeight;
              if (ratioMax &gt; 1) {
                  finalWidth = (int) ((float)maxHeight * ratioBitmap);
              } else {
                  finalHeight = (int) ((float)maxWidth / ratioBitmap);
              }
              image = Bitmap.createScaledBitmap(image, finalWidth, finalHeight, true);
              return image;
          } else {
              return image;
          }
      }
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          if (requestCode == ConstantsCustomGallery.REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK &amp;&amp; data != null) {
              //The array list has the image paths of the selected images
              ArrayList&lt;Image&gt; images = data.getParcelableArrayListExtra(ConstantsCustomGallery.INTENT_EXTRA_IMAGES);
  
              for (int i = 0; i &lt; images.size(); i++) {
  
                  Uri uri = Uri.fromFile(new File(images.get(i).path));
                  Bitmap bm = BitmapFactory.decodeFile(images.get(i).path);
                  Bitmap resized = resize(bm,512,512);
                  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                  resized.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
                  // ignore below line
                  //String encodedImage = Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT);
                  imageslist.add(resized);
                  // ignore below lines
                  //TextSliderView textSliderView = new TextSliderView(uploadimages.this);
                  //textSliderView.image(new File(images.get(i).path));
                  //mslider.addSlider(textSliderView);
  
  
              }
  }
  </code></pre>
  
  <p>Any help will be much appreciated </p>