code: public synchronized void upload(InputStream fileToUpload, String filename,
        String contents, String comment) throws Exception {
      TokenResult token = getEditToken("File:" + filename, "edit");
      final FormDataMultiPart multiPart = new FormDataMultiPart();
      // http://stackoverflow.com/questions/5772225/trying-to-upload-a-file-to-a-jax-rs-jersey-server
      multiPart.bodyPart(new StreamDataBodyPart("file", fileToUpload));
      multiPart.field("filename", filename);
      multiPart.field("ignorewarnings", "true");
      multiPart.field("text", contents);
      if (!comment.isEmpty())
        multiPart.field("comment", comment);
      String params = "";
      Api api = this.getActionResult("upload", params, token, multiPart);
      handleError(api);
    }
docs: upload from the given inputstream
  
  @param fileToUpload
  @param filename
  @param contents
  @param comment
  @throws Exception