code: public String getContentType() {
      if (contentType != null) {
        return contentType;
      }
  
      if (dataStream != null) {
        try {
          contentType = URLConnection.guessContentTypeFromStream(dataStream);
        } catch (IOException ioe) {
          // ignore exception
        }
      }
  
      if (data != null) {
        contentType = URLConnection.guessContentTypeFromName(filename);
      }
  
      // fallback - if we have no contenttype and cannot detect one, use 'application/octet-stream'
      if (contentType == null) {
        contentType = "application/octet-stream";
      }
  
      return contentType;
    }
docs: return the given content type or try to guess from stream or file name. Depending of the available data.
  
  @return the content type