@Override
  public <V> V postUpload(
      String uri,
      Map<String, String> stringParts,
      InputStream in,
      String mimeType,
      String fileName,
      final long fileSize,
      Class<V> type)
      throws IOException {
    HttpPost request = new HttpPost(createURI(uri));
    configureRequest(request);

    MultipartEntity entity = new MultipartEntity();
    for (Map.Entry<String, String> entry : stringParts.entrySet())
      entity.addPart(entry.getKey(), StringBody.create(entry.getValue(), "text/plain", UTF_8));

    entity.addPart(
        "file",
        new InputStreamBody(in, mimeType, fileName) {
          @Override
          public long getContentLength() {
            return fileSize;
          }
        });
    request.setEntity(entity);
    return executeRequest(request, type, null);
  }
  public void addPart(final String key, final StringBody value) {
    try {
      addPart(key, value.toString(), new FileInputStream(String.valueOf(value)));
    } catch (final FileNotFoundException e) {

    }
  }
  @Test
  public void testStringBody() throws Exception {
    StringBody b1 = new StringBody("text");
    Assert.assertEquals(4, b1.getContentLength());

    Assert.assertEquals("US-ASCII", b1.getCharset());

    Assert.assertNull(b1.getFilename());
    Assert.assertEquals("text/plain", b1.getMimeType());
    Assert.assertEquals("text", b1.getMediaType());
    Assert.assertEquals("plain", b1.getSubType());

    Assert.assertEquals(MIME.ENC_8BIT, b1.getTransferEncoding());

    StringBody b2 = new StringBody("more text", "text/other", MIME.DEFAULT_CHARSET);
    Assert.assertEquals(9, b2.getContentLength());
    Assert.assertEquals(MIME.DEFAULT_CHARSET.name(), b2.getCharset());

    Assert.assertNull(b2.getFilename());
    Assert.assertEquals("text/other", b2.getMimeType());
    Assert.assertEquals("text", b2.getMediaType());
    Assert.assertEquals("other", b2.getSubType());

    Assert.assertEquals(MIME.ENC_8BIT, b2.getTransferEncoding());
  }