Retrieve the mime type associates with the file extension (default is "application/octet-stream")

@param {String} fileExtension
@return {String}
513069
function _gpfGetMimeType (fileExtension) {
    var mimeType = _gpfMimeTypesFromExtension[fileExtension.toLowerCase()];
    if (undefined === mimeType) {
        // Default
        mimeType = "application/octet-stream";
    }
    return mimeType;
}
1372610
protected function _getMime($filename, $default = 'application/octet-stream') {
		if (!isset($this->_Mime)) {
			$this->_Mime = new Mime();
		}
		$mime = $this->_Mime->detectMimeType($filename);
		// Some environments falsely return the default too fast, better fallback to extension here
		if (!$mime || $mime === $default) {
			$ext = pathinfo($filename, PATHINFO_EXTENSION);
			$mime = $this->_Mime->getMimeTypeByAlias($ext);
		}
		return $mime;
	}
1010454
function MIME() {

  var self = this;

  this.types = Object.create( null );
  this.extensions = Object.create( null );

  for ( var type in typesData ) {
    var exts = typesData[ type ];
    self.extensions[ type ] = exts;
    exts.forEach( function( ext ) {
        self.types[ ext ] = type;
    });
  }

  this.default = this.types[ 'bin' ];

}
1011856
public function getMimeType($path, $default = "application/octet-stream")
    {

        $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $fmtype = finfo_file($finfo, $path);

        finfo_close($finfo);

        return !empty($fmtype) ? $fmtype : $default;
    }
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 "";
        }
    }
227935
public static String getMimeTypeFromExtension(String extension) {
        if (extension == null || extension.length() == 0) {
            return null;
        }
        return extensionToMimeTypeMap.get(extension);
    }
816383
public static String fileExtensionForMIMEType(String mimeType) {
        loadMappings();

        String ext = mimeTypeToExtensionMap.get(mimeType);

        if (ext == null) ext = "dat";

        return ext;
    }
1074636
public function getTypeByExtension($extension)
    {
        if ($this->isValidExtension($extension)) {

            // We get back flipped copy
            $list = $this->getList(true);
            return $list[$extension];

        } else {

            // For all unknown extensions, the default Mime-Type is used
            return 'application/octet-stream';
        }
    }
23672
def get_content_type(local_file_path)
      png = Regexp.new("\x89PNG".force_encoding("binary"))
      jpg = Regexp.new("\xff\xd8\xff\xe0\x00\x10JFIF".force_encoding("binary"))
      jpg2 = Regexp.new("\xff\xd8\xff\xe1(.*){2}Exif".force_encoding("binary"))
      case IO.read(local_file_path, 10)
      when /^GIF8/
        'image/gif'
      when /^#{png}/
        'image/png'
      when /^#{jpg}/
        'image/jpeg'
      when /^#{jpg2}/
        'image/jpeg'
      else
        if local_file_path.end_with? '.txt'
          'text/plain'
        else
          'application/octet-stream'
        end
        # mime_type = `file #{local_file_path} --mime-type`.gsub("\n", '') # Works on linux and mac
        # raise UnprocessableEntity, "unknown file type" if !mime_type
        # mime_type.split(':')[1].split('/')[1].gsub('x-', '').gsub(/jpeg/, 'jpg').gsub(/text/, 'txt').gsub(/x-/, '')
      end
    end
1097169
public static function getMimeByExtension(string $extension): string
    {
        $extension = strtolower($extension);

        if (!isset(static::$types[$extension])) {
            throw new HttpException("Unknown file extension={$extension}");
        }

        return static::$types[$extension];
    }
511782
public static function getMimeByLocalFile($filename, $default = 'application/octet-stream')
    {
        $type = false;

        // For local files we can detect type by the file content.
        if (!stream_is_local($filename) || !file_exists($filename)) {
            return false;
        }

        // Prefer using finfo if it exists.
        if (\extension_loaded('fileinfo')) {
            $finfo = finfo_open(FILEINFO_SYMLINK | FILEINFO_MIME_TYPE);
            $type = finfo_file($finfo, $filename);
            finfo_close($finfo);
        } else {
            // Fall back to use getimagesize() if it is available (not recommended, but better than nothing)
            $info = @getimagesize($filename);
            if ($info) {
                $type = $info['mime'];
            }
        }

        return $type ?: static::getMimeByFilename($filename, $default);
    }
1372115
function processFile(extension) {
  return (file, callback) => {
    let filePath;
    if (file.meta !== undefined && file.meta.filePath !== undefined) {
      const ext = extension === null
        ? file.meta.filePath.ext
        : extension;
      filePath = path.format(Object.assign({}, file.meta.filePath, { ext }));
    } else {
      filePath = extension === undefined
        ? file.path
        : `${trimExtension(file.path)}${extension}`;
    }

    async.nextTick(callback, null, Object.assign({}, file, { path: filePath }));
  };
}
1118458
public static function getMimeTypeFromFilename($fileName)
    {
        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (array_key_exists($ext, self::$customMimeTypes)) {
            return self::$customMimeTypes[$ext];
        } else if (array_key_exists($ext, self::$mimeTypes)) {
            return self::$mimeTypes[$ext];
        }
        return 'application/octet-stream';
    }
798230
def mimetype(path)
      extension = File.basename(path).split('.')[-1]
      Rack::Mime.mime_type(".#{extension}")
    end
516058
function get_extension($type)
    {
        $type = strtolower($type);
        foreach ($this->mime_types as $ext => $m_type) {
            if ($m_type == $type) return $ext;
        }
        return false;
    }
1219397
protected function getMimeByExtension($extension)
    {
        if (!isset($this->mimetypes[ $extension ])) {
            $this->addReturn('file_mimes', 'error_mimes', [ ':ext' => $extension ]);

            return false;
        }

        return $this->mimetypes[ $extension ];
    }
179535
function getFileExtension(file) {
    return file.name.substring(file.name.lastIndexOf('.')+1, file.name.length).toLowerCase()
}