code: public String upload(InputStream in) throws IOException {
          File tempFile = File.createTempFile("fedora-upload-", null);
          FileOutputStream out = new FileOutputStream(tempFile);
          try {
              StreamUtility.pipeStream(in, out, 8192);
              return upload(tempFile);
          } finally {
              in.close();
              out.close();
              if (!tempFile.delete()) {
                  System.err.println("WARNING: Could not remove temporary file: "
                          + tempFile.getName());
                  tempFile.deleteOnExit();
              }
          }
      }
docs: Send the data from the stream to the server. This is less efficient than
  <i>upload(File)</i>, but if you already have a stream, it's convenient.
  This method takes care of temporarily making a File out of the stream,
  making the request, and removing the temporary file. Having a File source
  for the upload is necessary because the content-length must be sent along
  with the request as per the HTTP Multipart POST protocol spec.