return the mime type of a file, dont check extension

@param barr
@return mime type of the file
@throws IOException
181738
public static String getMimeType(byte[] barr, String defaultValue) {
	PrintStream out = System.out;
	try {
	    Tika tika = new Tika();
	    return tika.detect(barr);
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    return defaultValue;
	}
    }
282330
public static final String getModeString(Path path) throws IOException
    {
        char letter = getFileTypeLetter(path);
        if (supports("posix"))
        {
            Set<PosixFilePermission> perms = Files.getPosixFilePermissions(path);
            return letter+PosixFilePermissions.toString(perms);
        }
        else
        {
            switch (letter)
            {
                case '-':
                    return "-rw-r--r--";
                case 'd':
                    return "drwxr-xr-x";
                case 'l':
                    return "drw-r--r--";
            }
        }
        throw new UnsupportedOperationException("should not happen");
    }
1043880
public ByteBuffer getByteBuffer() throws IOException
    {
        return rwChannel.map( FileChannel.MapMode.READ_ONLY, 0, file.length() );
    }
1271788
public String getMimeType() {
		FileItemWrap fileItem = getFile();
		if (fileItem != null) {
			return FileUtil.getFileMimeType(fileItem);
		}
		return null;
	}
1343719
@OverrideOnDemand
  @Nullable
  protected String determineMimeType (@Nonnull final String sFilename, @Nonnull final IReadableResource aResource)
  {
    return MimeTypeInfoManager.getDefaultInstance ().getPrimaryMimeTypeStringForFilename (sFilename);
  }
889670
public static String getMediaTypeForFileSuffix(String fileName) {
    String mediaType = "application/octet-stream"; // default
    if (fileName != null) {
      fileName = fileName.toLowerCase();
      if (fileName.endsWith(".png")) {
        mediaType = "image/png";
      } else if (fileName.endsWith(".svg")) {
        mediaType = "image/svg+xml";
      } else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
        mediaType = "image/jpeg";
      } else if (fileName.endsWith(".gif")) {
        mediaType = "image/gif";
      } else if (fileName.endsWith(".bmp")) {
        mediaType = "image/bmp";
      }
    }
    return mediaType;
  }
1314925
private static function getMimeTypeOfFile($path)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime     = finfo_file($fileInfo, $path);
        finfo_close($fileInfo);

        return $mime;
    }
366467
public function getMimeType()
	{
		$finfo = finfo_open(FILEINFO_MIME_TYPE);
		$mime = finfo_file($finfo, $this->path);
		finfo_close($finfo);

		return $mime;
	}
720100
public String getMimeType()
   {
      if (mediaType == null || untrustedAgent)
      {
         return mimeTypeResolver.getMimeType(fileName);
      }

      return mediaType.getType() + "/" + mediaType.getSubtype();
   }
270926
def guess_mime_type(self, path):
		
		_, ext = posixpath.splitext(path)
		if ext in self.extensions_map:
			return self.extensions_map[ext]
		ext = ext.lower()
		return self.extensions_map[ext if ext in self.extensions_map else '']
187459
def _get_content_type(self, file):
        
        if file.mimetype:
            return file.mimetype

        # get file extension
        _, extension = os.path.splitext(file.name)
        extension = extension.strip('.')

        # Make an educated guess about what the Content-Type should be.
        return media_types[extension] if extension in media_types else 'binary/octet-stream'
245515
private static final String getExtension(String MIMETYPE) throws Exception {
        if (m_extensionMappings == null) {
            m_extensionMappings = readExtensionMappings(Server.FEDORA_HOME + "/server/" + Server.CONFIG_DIR + "/" + DATASTREAM_MAPPING_SOURCE_FILE);
        }

        String extension = m_extensionMappings.get(MIMETYPE);
        if (extension != null) {
            return extension;
        } else {
            return "";
        }
    }
910291
function getTypeFromFileExtension(url) {
	url = url.toLowerCase().split('?')[0];
	var _ext = url.substring(url.lastIndexOf('.') + 1);
	var _av = /mp4|m4v|ogg|ogv|m3u8|webm|webmv|wmv|mpeg|mov/gi.test(_ext) ? 'video/' : 'audio/';

	switch (_ext) {
		case 'mp4':
		case 'm4v':
		case 'm4a':
			return _av + 'mp4';
		case 'webm':
		case 'webma':
		case 'webmv':
			return _av + 'webm';
		case 'ogg':
		case 'oga':
		case 'ogv':
			return _av + 'ogg';
		case 'm3u8':
			return 'application/x-mpegurl';
		case 'ts':
			return _av + 'mp2t';
		default:
			return _av + _ext;
	}
}
541763
def get_mime(self, path, isdir):
        ''''''
        if isdir:
            file_type = FOLDER
        else:
            file_type = mimetypes.guess_type(path)[0]
            if not file_type:
                file_type = UNKNOWN
        return file_type
125149
public static String findMimeType( File imgFile ) {

		String result;
		String name = imgFile.getName().toLowerCase();
		if( name.endsWith( ".jpg" ) || name.endsWith( ".jpeg" ))
			result = MIME_JPG;
		else if( name.endsWith( ".gif" ))
			result = MIME_GIF;
		else if( name.endsWith( ".png" ))
			result = MIME_PNG;
		else if( name.endsWith( ".svg" ))
			result = MIME_SVG;
		else
			result = MIME_BINARY;

		return result;
	}
366150
public synchronized static Mimetypes getInstance() {
        if (mimetypes != null) return mimetypes;

        mimetypes = new Mimetypes();
        InputStream is = mimetypes.getClass().getResourceAsStream("/mime.types");
        if (is != null) {
            if (log.isDebugEnabled()) {
                log.debug("Loading mime types from file in the classpath: mime.types");
            }
            try {
                mimetypes.loadAndReplaceMimetypes(is);
            } catch (IOException e) {
                if (log.isErrorEnabled()) {
                    log.error("Failed to load mime types from file in the classpath: mime.types", e);
                }
            } finally {
                try { is.close(); } catch (IOException ex) { log.debug("", ex); }
            }
        } else {
            if (log.isWarnEnabled()) {
                log.warn("Unable to find 'mime.types' file in classpath");
            }
        }
        return mimetypes;
    }
157254
def _file_type(file):
    
    # %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Verification of file type %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if "." in file:  # File with known extension.
        file_type = file.split(".")[-1]
    else:  # File without known extension.
        file_type = magic.from_file(file, mime=True).split("/")[-1]

    return file_type