spring-framework / org.springframework.http / MediaTypeFactory / getMediaType

getMediaType

open static fun getMediaType(@Nullable resource: Resource): Optional<MediaType>

Determine a media type for the given resource, if possible.

Parameters

resource - the resource to introspect

Return
the corresponding media type, or null if none found

open static fun getMediaType(@Nullable filename: String): Optional<MediaType>

Determine a media type for the given file name, if possible.

Parameters

filename - the file name plus extension

Return
the corresponding media type, or null if none found