public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') {
		if (!$reference_name) {
			$reference_name = basename($file_path);
		}

		$extension = pathinfo($reference_name, PATHINFO_EXTENSION);
		if ($extension and $mime_type = static::getTypeForExtension($extension)) {
			return $mime_type;
		}

		// While it's true that the extension doesn't determine the type,
		// only use finfo as a fallback because it's bad at detecting text
		// types like CSS and JavaScript.
		if ($mime_type = static::getMagicType($file_path)) {
			return $mime_type;
		}

		return $default;
	}