类 MediaTypeFactory

java.lang.Object
cn.taketoday.http.MediaTypeFactory

public abstract class MediaTypeFactory extends Object
A factory delegate for resolving MediaType objects from Resource handles or filenames.
从以下版本开始:
4.0 2022/2/15 14:33
作者:
Juergen Hoeller, Arjen Poutsma, Harry Yang
  • 字段详细资料

    • MIME_TYPES_FILE_NAME

      private static final String MIME_TYPES_FILE_NAME
      另请参阅:
    • fileExtensionToMediaTypes

      private static final cn.taketoday.util.MultiValueMap<String,MediaType> fileExtensionToMediaTypes
  • 构造器详细资料

    • MediaTypeFactory

      private MediaTypeFactory()
  • 方法详细资料

    • parseMimeTypes

      private static cn.taketoday.util.MultiValueMap<String,MediaType> parseMimeTypes()
      Parse the mime.types file found in the resources. Format is: # comments begin with a '#'
      # the format is <mime type> <space separated file extensions>
      # for example:
      text/plain txt text
      # this would map file.txt and file.text to
      # the mime type "text/plain"
      返回:
      a multi-value map, mapping media types to file extensions.
    • getMediaType

      public static Optional<MediaType> getMediaType(@Nullable cn.taketoday.core.io.Resource resource)
      Determine a media type for the given resource, if possible.
      参数:
      resource - the resource to introspect
      返回:
      the corresponding media type, or null if none found
    • getMediaType

      public static Optional<MediaType> getMediaType(@Nullable String filename)
      Determine a media type for the given file name, if possible.
      参数:
      filename - the file name plus extension
      返回:
      the corresponding media type, or null if none found
    • getMediaTypes

      public static List<MediaType> getMediaTypes(@Nullable String filename)
      Determine the media types for the given file name, if possible.
      参数:
      filename - the file name plus extension
      返回:
      the corresponding media types, or an empty list if none found