docs: public Node uploadFile( Session session,
                              String path,
                              InputStream stream ) throws RepositoryException, IOException {
          isNotNull(session, "session");
          isNotNull(path, "path");
          isNotNull(stream, "stream");
          Node fileNode = null;
          boolean error = false;
          try {
              // Create an 'nt:file' node at the supplied path, creating any missing intermediate nodes of type 'nt:folder' ...
              fileNode = findOrCreateNode(session.getRootNode(), path, "nt:folder", "nt:file");
  
              // Upload the file to that node ...
              Node contentNode = findOrCreateChild(fileNode, "jcr:content", "nt:resource");
              Binary binary = session.getValueFactory().createBinary(stream);
              contentNode.setProperty("jcr:data", binary);
          } catch (RepositoryException e) {
              error = true;
              throw e;
          } catch (RuntimeException e) {
              error = true;
              throw e;
          } finally {
              try {
                  stream.close();
              } catch (RuntimeException e) {
                  if (!error) throw e; // don't override any exception thrown in the block above
              }
          }
          return fileNode;
      }