@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);
  }