code: public static MimeType getMimeType(String name, Property property) {
          MimeType result = null;
          try {
              Binary binary = property != null ? property.getBinary() : null;
              if (binary != null) {
                  try {
                      InputStream input = binary.getStream();
                      try {
                          MediaType mediaType = getMediaType(input, name);
                          if (mediaType != null) {
                              try {
                                  result = getMimeTypes().forName(mediaType.toString());
                              } catch (MimeTypeException e1) {
                                  // detection not successful
                              }
                          }
                      } finally {
                          try {
                              input.close();
                          } catch (IOException ioex) {
                              LOG.error(ioex.toString());
                          }
                      }
                  } finally {
                      binary.dispose();
                  }
              }
          } catch (RepositoryException rex) {
              LOG.error(rex.toString());
          }
          return result;
      }
docs: Detects the mime type of a binary property in the context of the nodes name.
  
  @param name     the name of the node which defines the binary resource (probably a file name)
  @param property the binary property (for stream parsing)
  @return he detected mime type or 'null' if the detection was not successful