code: protected String getContentType(Resource resource, @SuppressWarnings("unused") SlingHttpServletRequest request) {
      String mimeType = JcrBinary.getMimeType(resource);
      if (StringUtils.isEmpty(mimeType)) {
        mimeType = ContentType.OCTET_STREAM;
      }
      return mimeType;
    }
docs: Get content type from the reference nt:file or nt:resourcer resource.
  @param resource Resource
  @return Content type (never null)