code: public String uploadFile(File file) throws IOException {
          HttpPost post = null;
          try {
              // prepare the post method
              post = new HttpPost(getUploadURL());
              post.getParams().setParameter("Connection", "Keep-Alive");
  
              // add the file part
              MultipartEntity entity = new MultipartEntity();
              entity.addPart("file", new FileBody(file));
              post.setEntity(entity);
  
              // execute and get the response
              HttpResponse response = getHttpClient().execute(post);
              int responseCode = response.getStatusLine().getStatusCode();
              String body = null;
              try {
                  if (response.getEntity() != null) {
                      body = EntityUtils.toString(response.getEntity());
                  }
              } catch (Exception e) {
                  logger.warn("Error reading response body", e);
              }
              if (body == null) {
                  body = "[empty response body]";
              }
              body = body.trim();
              if (responseCode != HttpStatus.SC_CREATED) {
                  throw new IOException("Upload failed: "
                          + response.getStatusLine().getReasonPhrase()
                          + ": " + replaceNewlines(body, " "));
              } else {
                  return replaceNewlines(body, "");
              }
          } finally {
              if (post != null) {
                  post.releaseConnection();
              }
          }
      }
docs: Upload the given file to Fedora's upload interface via HTTP POST.
  
  @return the temporary id which can then be passed to API-M requests as a
  URL. It will look like uploaded://123